Conditions | 7 |
Total Lines | 23 |
Lines | 0 |
Ratio | 0 % |
Tests | 18 |
CRAP Score | 7 |
1 | """Classes and functions to interact with sharing services.""" |
||
15 | 1 | def find(home=None): |
|
16 | """Return the path to a sharing location.""" |
||
17 | |||
18 | 1 | home = home or os.path.expanduser("~") |
|
19 | |||
20 | 1 | logging.debug("looking for service in {}...".format(home)) |
|
21 | 1 | for directory in os.listdir(home): |
|
22 | 1 | if directory in SERVICES: |
|
23 | 1 | service = os.path.join(home, directory) |
|
24 | 1 | logging.debug("found service: {}".format(service)) |
|
25 | 1 | logging.debug("looking for '{}' in {}...".format(SHARE, service)) |
|
26 | 1 | for dirpath, dirnames, _, in os.walk(service): |
|
27 | 1 | depth = dirpath.count(os.path.sep) - service.count(os.path.sep) |
|
28 | 1 | if depth >= SHARE_DEPTH: |
|
29 | 1 | del dirnames[:] |
|
30 | 1 | continue |
|
31 | 1 | path = os.path.join(dirpath, SHARE) |
|
32 | 1 | if os.path.isdir(path) and \ |
|
33 | not os.path.isfile(os.path.join(path, 'setup.py')): |
||
34 | 1 | logging.info("found share: {}".format(path)) |
|
35 | 1 | return path |
|
36 | |||
37 | raise EnvironmentError("no '{}' folder found".format(SHARE)) |
||
38 |