text stringlengths 0 828 |
|---|
:return: |
"""""" |
if blank_parent_part: |
idx = len(self.location) |
return (' ' * (idx-3)) + '|--' + child_name |
else: |
# TODO sep should be replaced with the appropriate separator in flat mode |
return self.location + sep + child_name" |
1344,"def create_persisted_object(self, location: str, logger: Logger) -> PersistedObject: |
"""""" |
Creates a PersistedObject representing the object at location 'location', and recursively creates all of its |
children |
:param location: |
:param logger: |
:return: |
"""""" |
#print('Checking all files under ' + location) |
logger.debug('Checking all files under [{loc}]'.format(loc=location)) |
obj = FileMappingConfiguration.RecursivePersistedObject(location=location, file_mapping_conf=self, |
logger=logger) |
#print('File checks done') |
logger.debug('File checks done') |
return obj" |
1345,"def find_multifile_object_children(self, parent_location, no_errors: bool = False) -> Dict[str, str]: |
"""""" |
Implementation of the parent abstract method. |
In this mode, root_path should be a valid folder, and each item is a subfolder (multifile) or a file |
(singlefile): |
location/ |
|-singlefile_sub_item1.<ext> |
|-singlefile_sub_item2.<ext> |
|-multifile_sub_item3/ |
|- ... |
:param parent_location: the absolute file prefix of the parent item. it may be a folder (non-flat mode) |
or a folder + a file name prefix (flat mode) |
:param no_errors: a boolean used in internal recursive calls in order to catch errors. Should not be changed by |
users. |
:return: a dictionary of {item_name : item_prefix} |
"""""" |
# (1) Assert that folder_path is a folder |
if not isdir(parent_location): |
if no_errors: |
return dict() |
else: |
raise ValueError('Cannot find a multifileobject at location \'' + parent_location + '\' : location is ' |
'not a valid folder') |
else: |
# (2) List folders (multifile objects or collections) |
all_subfolders = [dir_ for dir_ in listdir(parent_location) if isdir(join(parent_location, dir_))] |
items = {item_name: join(parent_location, item_name) for item_name in all_subfolders} |
# (3) List singlefiles *without* their extension |
items.update({ |
item_name: join(parent_location, item_name) |
for item_name in [file_name[0:file_name.rindex(EXT_SEPARATOR)] |
for file_name in listdir(parent_location) |
if isfile(join(parent_location, file_name)) |
and EXT_SEPARATOR in file_name] |
}) |
# (4) return all |
return items" |
1346,"def is_multifile_object_without_children(self, location: str) -> bool: |
"""""" |
Returns True if an item with this location is present as a multifile object without children. |
For this implementation, this means that there is a folder without any files in it |
:param location: |
:return: |
"""""" |
return isdir(location) and len(self.find_multifile_object_children(location)) == 0" |
1347,"def get_multifile_object_child_location(self, parent_item_prefix: str, child_name: str) -> str: |
"""""" |
Implementation of the parent abstract method. |
In this mode the attribute is a file inside the parent object folder |
:param parent_item_prefix: the absolute file prefix of the parent item. |
:return: the file prefix for this attribute |
"""""" |
check_var(parent_item_prefix, var_types=str, var_name='parent_item_prefix') |
check_var(child_name, var_types=str, var_name='item_name') |
# assert that folder_path is a folder |
if not isdir(parent_item_prefix): |
raise ValueError( |
'Cannot get attribute item in non-flat mode, parent item path is not a folder : ' + parent_item_prefix) |
return join(parent_item_prefix, child_name)" |
1348,"def find_multifile_object_children(self, parent_location, no_errors: bool = False) -> Dict[str, str]: |
"""""" |
Implementation of the parent abstract method. |
In this mode, each item is a set of files with the same prefix than location, separated from the |
attribute name by the character sequence <self.separator>. The location may also be directly a folder, |
in which case the sub items dont have a prefix. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.