Add note when no documents are available on DPE portal

master
Dan Howe 6 years ago
parent ee718fd7c3
commit 6df59b9b7d

@ -46,6 +46,23 @@ def get_documents(mod_id, output_dir):
# Get list of document folders # Get list of document folders
folders = mod_tree.xpath('//div[@class="folder_row"]') folders = mod_tree.xpath('//div[@class="folder_row"]')
# Create modification folder
mod_dir = os.path.join(output_dir, project_name, mod_name)
os.makedirs(mod_dir, exist_ok=True)
# Add note if no documents are found on portal
if not folders:
txt_name = 'No documents on DPE portal for this modification.txt'
open(os.path.join(mod_dir,txt_name), 'a').close()
# Create link to DPE Major Projects page for current modification
text = """<html>
<meta http-equiv="refresh" content="0; url={}">
</html>""".format(mod_url)
with open(os.path.join(mod_dir, 'DPE-portal-page.html'), 'w') as f:
f.write(text)
for folder in folders: for folder in folders:
folder_name = folder.xpath('a[2]')[0].text.strip() folder_name = folder.xpath('a[2]')[0].text.strip()
@ -122,7 +139,11 @@ def main():
parser.add_argument( parser.add_argument(
'-o', metavar='OUTPUT_DIR', default='.', help='root output directory') '-o', metavar='OUTPUT_DIR', default='.', help='root output directory')
parser.add_argument( parser.add_argument(
'-i', metavar='ID', default=[], help='modification job id(s)', nargs='*') '-i',
metavar='ID',
default=[],
help='modification job id(s)',
nargs='*')
parser.add_argument('-u', metavar='URL', help='url of search results page') parser.add_argument('-u', metavar='URL', help='url of search results page')
# Print usage if no arguments are provided # Print usage if no arguments are provided

Loading…
Cancel
Save