@@ -144,7 +144,7 @@ class StaticFetcher(_BaseFetcher):
144144
145145 Attributes
146146 ----------
147- cache_path : pathlib.Path or ``None``
147+ cache_path : pathlib.Path
148148 Path to the cache directory.
149149
150150 hash : str
@@ -225,16 +225,20 @@ def fetch(
225225
226226 Examples
227227 --------
228- Download a single CIF file from the RCSB Protein Data Bank.
229228
230- >>> StaticFetcher().fetch(file_name="1AKE.cif",
231- base_url="https://files.wwpdb.org/download/")
232- './MDAnalysis_pdbs/1AKE.cif'
229+ .. code-block:: pycon
233230
234- Download multiple CIF files from the RCSB Protein Data Bank.
235- >>> StaticFetcher().fetch(file_name=["1AKE.cif", "4AKE.cif"],
236- base_url="https://files.wwpdb.org/download/")
237- ['./MDAnalysis_pdbs/1AKE.cif', './MDAnalysis_pdbs/4AKE.cif']
231+ Download a single CIF file from the RCSB Protein Data Bank.
232+
233+ >>> StaticFetcher().fetch(file_name="1AKE.cif",
234+ base_url="https://files.wwpdb.org/download/")
235+ './MDAnalysis_pdbs/1AKE.cif'
236+
237+ Download multiple CIF files from the RCSB Protein Data Bank.
238+
239+ >>> StaticFetcher().fetch(file_name=["1AKE.cif", "4AKE.cif"],
240+ base_url="https://files.wwpdb.org/download/")
241+ ['./MDAnalysis_pdbs/1AKE.cif', './MDAnalysis_pdbs/4AKE.cif']
238242
239243 Notes
240244 -----
@@ -345,6 +349,10 @@ def append_registry(self, db_path, files, write_duplicate=False):
345349 files : iterable of str or path-like
346350 File names or paths for cached files to append to the registry. Relative
347351 paths are interpreted relative to :attr:`cache_path`.
352+ write_duplicate : bool
353+ If set to True, append_registry will write the file and its hash to the registry
354+ regardless of the existing presence of a entry in the registry. Default behavior is
355+ False.
348356
349357 Returns
350358 -------
@@ -426,24 +434,25 @@ def check_registry(self, db_path, files=None, ignore=None):
426434 Example
427435 -------
428436 .. code-block:: python
429- >>> files = {
430- ... "file1.txt": "Molecular \\ n",
431- ... "file2.txt": "Dynamics. \\ n",
432- ... "file3.txt": "Analysis. \\ n"
433- ... }
434- >>> for filename, content in files.items():
435- ... with open(filename, "w") as f:
436- ... f.write(content)
437- ...
438- >>> fetcher = StaticFetcher()
439- >>> fetcher.write_registry(
440- ... "file_1_2_and_3_hash.txt",
441- ... files=["file1.txt"],
442- ... )
443- >>> fetcher.check_registry("file_1_2_and_3_hash.txt")
444- [Path('./MDAnalysis_pdbs/file3.txt'), Path('./MDAnalysis_pdbs/file2.txt')]
445- >>> fetcher.check_registry("file_1_2_and_3_hash.txt", ignore=["file2.txt"])
446- [Path('./MDAnalysis_pdbs/file3.txt')]
437+
438+ >>> files = {
439+ ... "file1.txt": "Molecular \\ n",
440+ ... "file2.txt": "Dynamics. \\ n",
441+ ... "file3.txt": "Analysis. \\ n"
442+ ... }
443+ >>> for filename, content in files.items():
444+ ... with open(filename, "w") as f:
445+ ... f.write(content)
446+ ...
447+ >>> fetcher = StaticFetcher()
448+ >>> fetcher.write_registry(
449+ ... "file_1_2_and_3_hash.txt",
450+ ... files=["file1.txt"],
451+ ... )
452+ >>> fetcher.check_registry("file_1_2_and_3_hash.txt")
453+ [Path('./MDAnalysis_pdbs/file3.txt'), Path('./MDAnalysis_pdbs/file2.txt')]
454+ >>> fetcher.check_registry("file_1_2_and_3_hash.txt", ignore=["file2.txt"])
455+ [Path('./MDAnalysis_pdbs/file3.txt')]
447456
448457
449458 Notes
@@ -496,22 +505,22 @@ def read_registry(self, db_path):
496505 -------
497506 .. code-block:: python
498507
499- >>> files = {
500- ... "file1.txt": "Molecular \\ n",
501- ... "file2.txt": "Dynamics. \\ n",
502- ... }
503- >>> for filename, content in files.items():
504- ... with open(filename, "w") as f:
505- ... f.write(content)
506- ...
507- >>> fetcher = StaticFetcher()
508- >>> fetcher.write_registry(
509- ... "file_1_and_2_hash.txt",
510- ... ["file1.txt", "file2.txt"],
511- ... )
512- >>> fetcher.read_registry("file_1_and_2_hash.txt")
513- {'file1.txt': 'sha256:2da169c5aae36a823c202da49fb11935b76277efcb5cd42a4cf238ddda2a9b20',
514- 'file2.txt': 'sha256:3a0dbd9e2abc4a7bbae6adfe92e2858218135926dacd4a7d3fb4ca2dbdbe457a'}
508+ >>> files = {
509+ ... "file1.txt": "Molecular \\ n",
510+ ... "file2.txt": "Dynamics. \\ n",
511+ ... }
512+ >>> for filename, content in files.items():
513+ ... with open(filename, "w") as f:
514+ ... f.write(content)
515+ ...
516+ >>> fetcher = StaticFetcher()
517+ >>> fetcher.write_registry(
518+ ... "file_1_and_2_hash.txt",
519+ ... ["file1.txt", "file2.txt"],
520+ ... )
521+ >>> fetcher.read_registry("file_1_and_2_hash.txt")
522+ {'file1.txt': 'sha256:2da169c5aae36a823c202da49fb11935b76277efcb5cd42a4cf238ddda2a9b20',
523+ 'file2.txt': 'sha256:3a0dbd9e2abc4a7bbae6adfe92e2858218135926dacd4a7d3fb4ca2dbdbe457a'}
515524
516525 Notes
517526 -----
@@ -557,22 +566,23 @@ def write_registry(self, db_path, files, mode="w"):
557566 Example
558567 -------
559568 .. code-block:: python
560- >>> files = {
561- ... "file1.txt": "Molecular \\ n",
562- ... "file2.txt": "Dynamics. \\ n",
563- ... }
564- >>> for filename, content in files.items():
565- ... with open(filename, "w") as f:
566- ... f.write(content)
567- ...
568- >>> fetcher = StaticFetcher()
569- >>> fetcher.write_registry(
570- ... "file_1_and_2_hash.txt",
571- ... ["file1.txt", "file2.txt"],
572- ... )
573- >>> Path("file_1_and_2_hash.txt").read_text()
574- file1.txt sha256:2da169c5aae36a823c202da49fb11935b76277efcb5cd42a4cf238ddda2a9b20
575- file2.txt sha256:3a0dbd9e2abc4a7bbae6adfe92e2858218135926dacd4a7d3fb4ca2dbdbe457a
569+
570+ >>> files = {
571+ ... "file1.txt": "Molecular \\ n",
572+ ... "file2.txt": "Dynamics. \\ n",
573+ ... }
574+ >>> for filename, content in files.items():
575+ ... with open(filename, "w") as f:
576+ ... f.write(content)
577+ ...
578+ >>> fetcher = StaticFetcher()
579+ >>> fetcher.write_registry(
580+ ... "file_1_and_2_hash.txt",
581+ ... ["file1.txt", "file2.txt"],
582+ ... )
583+ >>> Path("file_1_and_2_hash.txt").read_text()
584+ file1.txt sha256:2da169c5aae36a823c202da49fb11935b76277efcb5cd42a4cf238ddda2a9b20
585+ file2.txt sha256:3a0dbd9e2abc4a7bbae6adfe92e2858218135926dacd4a7d3fb4ca2dbdbe457a
576586
577587 Notes
578588 -----
0 commit comments