equal
deleted
inserted
replaced
17 """Document (Model) query functions. |
17 """Document (Model) query functions. |
18 """ |
18 """ |
19 |
19 |
20 __authors__ = [ |
20 __authors__ = [ |
21 '"Pawel Solyga" <pawel.solyga@gmail.com>', |
21 '"Pawel Solyga" <pawel.solyga@gmail.com>', |
|
22 '"Todd Larsen" <tlarsen@google.com>', |
22 ] |
23 ] |
23 |
24 |
24 |
25 |
25 import re |
26 import re |
26 |
27 |
32 |
33 |
33 import soc.logic.model |
34 import soc.logic.model |
34 |
35 |
35 import soc.models.document |
36 import soc.models.document |
36 import soc.models.work |
37 import soc.models.work |
37 |
|
38 |
|
39 WORK_PATH_LINKNAME_REGEX = re.compile(key_name.WORK_PATH_LINKNAME_PATTERN) |
|
40 |
|
41 def getPartsFromPath(path): |
|
42 """Splits path string into partial_path and link_name. |
|
43 |
|
44 Returns: |
|
45 {'partial_path': 'everything/but', |
|
46 'link_name': 'link_name'} |
|
47 or {} (empty dict) if string did not match WORK_PATH_LINKNAME_PATTERN. |
|
48 """ |
|
49 path_linkname_match = WORK_PATH_LINKNAME_REGEX.match(path) |
|
50 |
|
51 if not path_linkname_match: |
|
52 return {} |
|
53 |
|
54 return path_linkname_match.groupdict() |
|
55 |
38 |
56 |
39 |
57 def getDocument(path, link_name=None): |
40 def getDocument(path, link_name=None): |
58 """Returns Document entity for a given path, or None if not found. |
41 """Returns Document entity for a given path, or None if not found. |
59 |
42 |