コード例 #1
0
  def _get_directory(self, object_tree_folder, path):
    dir = directory.Directory()

    merged_region_tree = self._get_merged_region_tree(object_tree_folder)

    region_tree_item, unconsumed_path = self._get_region_tree_item_and_unconsumed_path(
      merged_region_tree, path
    )
    if self._region_tree_item_is_pid(region_tree_item):
      # If there is an unconsumed path section, the path exits through a valid
      # PID (any other exit would have raised an exception).
      #if len(unconsumed_path):
      return self._resource_map_resolver.get_directory(
        object_tree_folder,
        [region_tree_item] + unconsumed_path
      )
      #else:
      #  # The user has attempted to "dir" a PID.
      #  raise onedrive_exceptions.PathException('not a directory')

      # The whole path was consumed and a folder within the tree was returned.
    dir = directory.Directory()
    #if self._has_readme_entry(path):
    #  dir.append(self._get_readme_filename())

    for r in region_tree_item:
      dir.append(r)

    # Add readme.txt to root.
    if not path:
      dir.append('readme.txt')

    return dir
コード例 #2
0
ファイル: taxa.py プロジェクト: pombredanne/d1_python
 def _resolve_taxa_root(self, object_tree_folder):
     d = directory.Directory()
     for g in self._classifications:
         if g in object_tree_folder['items']:
             d.append(g)
             break
     return d
コード例 #3
0
ファイル: time_period.py プロジェクト: pombredanne/d1_python
 def _resolve_objects_in_year(self, year, object_tree_folder):
     dir = directory.Directory()
     for pid in object_tree_folder['items']:
         record = self._object_tree.get_object_record(pid)
         if 'beginDate' in record and 'endDate' in record:
             if self._is_year_in_date_range(year, record['beginDate'],
                                            record['endDate']):
                 dir.append(record['id'])
     self._raise_exception_if_empty_directory(dir)
     return dir
コード例 #4
0
ファイル: author.py プロジェクト: pombredanne/d1_python
 def _resolve_author_root(self, object_tree_folder):
     d = directory.Directory()
     authors = set()
     for pid in object_tree_folder['items']:
         try:
             authors.add(
                 self._object_tree.get_object_record(pid)[u'author'])
         except KeyError:
             pass
     d.extend(authors)
     return d
コード例 #5
0
ファイル: time_period.py プロジェクト: pombredanne/d1_python
 def _resolve_decades(self, object_tree_folder):
     dir = directory.Directory()
     sites = set()
     for pid in object_tree_folder['items']:
         record = self._object_tree.get_object_record(pid)
         if 'beginDate' in record and 'endDate' in record:
             for decade in self._decade_ranges_in_date_range(
                     record['beginDate'], record['endDate']):
                 sites.add(decade)
     dir.extend(sites)
     return dir
コード例 #6
0
ファイル: author.py プロジェクト: pombredanne/d1_python
 def _resolve_author(self, author, object_tree_folder):
     d = directory.Directory()
     for pid in object_tree_folder['items']:
         try:
             record = self._object_tree.get_object_record(pid)
             if record['author'] == author:
                 d.append(record['id'])
         except KeyError:
             pass
     # As each author folder in the root has at least one object, an empty folder
     # here can only be due to an invalid path.
     if not d:
         raise onedrive_exceptions.PathException(u'Invalid author')
     return d
コード例 #7
0
ファイル: time_period.py プロジェクト: pombredanne/d1_python
 def _resolve_years_in_decade(self, decade, object_tree_folder):
     first_year_in_decade = self._validate_and_split_decade_range(decade)[0]
     dir = directory.Directory()
     sites = set()
     for pid in object_tree_folder['items']:
         record = self._object_tree.get_object_record(pid)
         if 'beginDate' in record and 'endDate' in record:
             for year in self._years_in_date_range_within_decade(
                     first_year_in_decade, record['beginDate'],
                     record['endDate']):
                 sites.add(str(year))
     dir.extend(sites)
     self._raise_exception_if_empty_directory(dir)
     return dir
コード例 #8
0
ファイル: taxa.py プロジェクト: pombredanne/d1_python
 def _resolve_taxa_classification_value(self, classification, value,
                                        object_tree_folder):
     d = directory.Directory()
     for pid in object_tree_folder.get_records['items']:
         record = self._object_tree.get_object_record(pid)
         try:
             if value in record[classification]:
                 d.append(record['id'])
         except KeyError:
             pass
     # As empty folders in the taxa tree are pruned in the root and first level,
     # an empty folder here can only be due to an invalid path.
     if not len(d):
         raise onedrive_exceptions.PathException(
             u'Invalid taxonomic classification value')
     return d
コード例 #9
0
 def _resolve_object_tree_folder(self, object_tree_folder):
   dir = directory.Directory()
   self._append_folders(dir, object_tree_folder)
   dir.extend(self._resolvers.keys())
   return dir
コード例 #10
0
ファイル: root.py プロジェクト: pombredanne/d1_python
 def _escape_directory_entries(self, dir):
   return directory.Directory(
     os_escape.filename_from_identifier(d) for d in dir
   )
コード例 #11
0
ファイル: root.py プロジェクト: pombredanne/d1_python
 def _resolve_root(self):
   dir = directory.Directory()
   dir.extend(self._resolvers.keys())
   return dir
コード例 #12
0
 def _get_directory(self, object_tree_root, path):
     d = directory.Directory()
     d.append(self._get_readme_filename())
     d.extend(object_tree_root['items'])
     return d