From 92fa9ad7af413c419e6f127b851ecdb771f31028 Mon Sep 17 00:00:00 2001 From: Matthew Keitelman Date: Thu, 11 Aug 2016 09:59:44 -0400 Subject: [PATCH 1/3] Add profile to list and a warning --- scripts/make_flat.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/scripts/make_flat.py b/scripts/make_flat.py index 956b0a1..8a6a65e 100644 --- a/scripts/make_flat.py +++ b/scripts/make_flat.py @@ -1,8 +1,11 @@ #!/bin/python """ -Make the organization of the mirror flat so that relative URLs cooperate +Produces a flat_archive version of the archive without OSF category folders registration, profile, and project, so that relative URLs cooperate + archive/project/mst3k -> archive/mst3k +WARNING: Utilities will not work with a flattened archive + :param 1 in CLI: folder to flatten """ import os @@ -11,7 +14,7 @@ mirror = 'archive/' if len(sys.argv) < 2 else sys.argv[1] + '/' -inflated_directories = ['project/', 'registration/'] +inflated_directories = ['project/', 'registration/', 'profile/'] print("Flattening:", mirror) From 9b9c46a765c12cb042993dbb8dee66ab4961d299 Mon Sep 17 00:00:00 2001 From: Matthew Keitelman Date: Thu, 11 Aug 2016 10:32:40 -0400 Subject: [PATCH 2/3] Flatten wikis --- archive/search.html | 150 ------------------------------------------- scripts/make_flat.py | 38 +++++++---- 2 files changed, 26 insertions(+), 162 deletions(-) delete mode 100644 archive/search.html diff --git a/archive/search.html b/archive/search.html deleted file mode 100644 index 328e153..0000000 --- a/archive/search.html +++ /dev/null @@ -1,150 +0,0 @@ - - - - - Search - - - - - - -
- -

OSF Mirror Search

-
- - - - - -
- This page is a read-only mirror of the OSF. Some features may not be available. -
- - - \ No newline at end of file diff --git a/scripts/make_flat.py b/scripts/make_flat.py index 8a6a65e..0ff4d07 100644 --- a/scripts/make_flat.py +++ b/scripts/make_flat.py @@ -14,21 +14,35 @@ mirror = 'archive/' if len(sys.argv) < 2 else sys.argv[1] + '/' -inflated_directories = ['project/', 'registration/', 'profile/'] -print("Flattening:", mirror) +def make_wiki_flat(subdir): + wiki_home = subdir + '/wiki/home/index.html' + if os.path.exists(wiki_home): + shutil.copy(wiki_home, subdir + '/wiki/index.html') -for directory in inflated_directories: - path = 'archive/' + directory +def remove_organization(): + """ + Removes category folders and calls make_wiki_flat + :return: + """ + inflated_categories = ['project/', 'registration/', 'profile/'] + for category in inflated_categories: + category_path = 'archive/' + category - if not os.path.exists(path): - continue + if not os.path.exists(category_path): + continue - if os.path.exists(path + '/.DS_Store'): - os.remove(path + '/.DS_Store') + if os.path.exists(category_path + '/.DS_Store'): + os.remove(category_path + '/.DS_Store') - subdirs = os.listdir(path) - for dir in subdirs: - shutil.move(path + dir, 'archive/' + dir) - os.rmdir(path) + subdirs = os.listdir(category_path) + for dir in subdirs: + make_wiki_flat(dir) + shutil.move(category_path + dir, 'archive/' + dir) + os.rmdir(category_path) + +if __name__ == "__main__": + print("Flattening:", mirror) + + remove_organization() \ No newline at end of file From f25bb7f79acf91d77eb3b50b0d312ae7db37a976 Mon Sep 17 00:00:00 2001 From: Matthew Keitelman Date: Thu, 11 Aug 2016 14:47:01 -0400 Subject: [PATCH 3/3] Change docstring --- scripts/make_flat.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/make_flat.py b/scripts/make_flat.py index 0ff4d07..f4991b4 100644 --- a/scripts/make_flat.py +++ b/scripts/make_flat.py @@ -6,7 +6,7 @@ WARNING: Utilities will not work with a flattened archive -:param 1 in CLI: folder to flatten +:param for CLI use: directory to flatten """ import os import shutil