8000 xcat-core/create_man_pages.py at master · bybai/xcat-core · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
{"payload":{"allShortcutsEnabled":false,"fileTree":{"":{"items":[{"name":"build-utils","path":"build-utils","contentType":"directory"},{"name":"docs","path":"docs","contentType":"directory"},{"name":"java-xCAT","path":"java-xCAT","contentType":"directory"},{"name":"perl-xCAT","path":"perl-xCAT","contentType":"directory"},{"name":"src","path":"src","contentType":"directory"},{"name":"xCAT-IBMhpc","path":"xCAT-IBMhpc","contentType":"directory"},{"name":"xCAT-OpenStack-baremetal","path":"xCAT-OpenStack-baremetal","contentType":"directory"},{"name":"xCAT-OpenStack-ironic","path":"xCAT-OpenStack-ironic","contentType":"directory"},{"name":"xCAT-OpenStack","path":"xCAT-OpenStack","contentType":"directory"},{"name":"xCAT-SoftLayer","path":"xCAT-SoftLayer","contentType":"directory"},{"name":"xCAT-UI","path":"xCAT-UI","contentType":"directory"},{"name":"xCAT-buildkit","path":"xCAT-buildkit","contentType":"directory"},{"name":"xCAT-client","path":"xCAT-client","contentType":"directory"},{"name":"xCAT-confluent","path":"xCAT-confluent","contentType":"directory"},{"name":"xCAT-csm","path":"xCAT-csm","contentType":"directory"},{"name":"xCAT-genesis-builder","path":"xCAT-genesis-builder","contentType":"directory"},{"name":"xCAT-genesis-scripts","path":"xCAT-genesis-scripts","contentType":"directory"},{"name":"xCAT-openbmc-py","path":"xCAT-openbmc-py","contentType":"directory"},{"name":"xCAT-probe","path":"xCAT-probe","contentType":"directory"},{"name":"xCAT-rmc","path":"xCAT-rmc","contentType":"directory"},{"name":"xCAT-server","path":"xCAT-server","contentType":"directory"},{"name":"xCAT-test","path":"xCAT-test","contentType":"directory"},{"name":"xCAT-vlan","path":"xCAT-vlan","contentType":"directory"},{"name":"xCAT","path":"xCAT","contentType":"directory"},{"name":"xCATsn","path":"xCATsn","contentType":"directory"},{"name":".gitignore","path":".gitignore","contentType":"file"},{"name":".mailmap","path":".mailmap","contentType":"file"},{"name":".travis.yml","path":".travis.yml","contentType":"file"},{"name":"README.md","path":"README.md","contentType":"file"},{"name":"Release","path":"Release","contentType":"file"},{"name":"Version","path":"Version","contentType":"file"},{"name":"_config.yml","path":"_config.yml","contentType":"file"},{"name":"build-python-deb","path":"build-python-deb","contentType":"file"},{"name":"build-ubunturepo","path":"build-ubunturepo","contentType":"file"},{"name":"buildcore.sh","path":"buildcore.sh","contentType":"file"},{"name":"builddep.sh","path":"builddep.sh","contentType":"file"},{"name":"buildlocal.sh","path":"buildlocal.sh","contentType":"file"},{"name":"comps.xml","path":"comps.xml","contentType":"file"},{"name":"create_man_pages.py","path":"create_man_pages.py","contentType":"file"},{"name":"makerpm","path":"makerpm","contentType":"file"},{"name":"makerpm-genesisbuilder","path":"makerpm-genesisbuilder","contentType":"file"},{"name":"pull_request_template.md","path":"pull_request_template.md","contentType":"file"},{"name":"travis.pl","path":"travis.pl","contentType":"file"}],"totalCount":43}},"fileTreeProcessingTime":33.55998,"foldersToFetch":[],"incompleteFileTree":false,"repo":{"id":40161258,"defaultBranch":"master","name":"xcat-core","ownerLogin":"bybai","currentUserCanPush":false,"isFork":true,"isEmpty":false,"createdAt":"2015-08-04T03:26:05.000Z","ownerAvatar":"https://avatars.githubusercontent.com/u/6743951?v=4","public":true,"private":false,"isOrgOwned":false},"codeLineWrapEnabled":false,"symbolsExpanded":false,"treeExpanded":true,"refInfo":{"name":"master","listCacheKey":"v0:1558062213.0","canEdit":false,"refType":"branch","currentOid":"dc152dfb11fd6d0f1640989e452ba85fd0f9f203"},"path":"create_man_pages.py","currentUser":null,"blob":{"rawLines":["#!/usr/bin/env python","#TODO: Delete the old files to support removing a man page","","import glob","import os","import sys","import subprocess","from glob import glob","import shutil","","from optparse import OptionParser","","usage = \"usage: %prog [options]\"","","parser = OptionParser(usage=usage)","parser.add_option(\"--prefix\", dest=\"PREFIX\", help=\"Specify the location of the Perl modules\")","","(options, args) = parser.parse_args()","","POD2RST=\"pod2rst\"","","def cmd_exists(cmd):"," return subprocess.call(\"type \" + cmd, shell=True,"," stdout=subprocess.PIPE, stderr=subprocess.PIPE) == 0","","prefix_path = None","prefix_lib_path = None","","if options.PREFIX:"," if '~' in options.PREFIX:"," # else assume full path is provided"," prefix_path = os.path.expanduser(options.PREFIX)"," else:"," prefix_path = options.PREFIX",""," if not cmd_exists(\"%s/bin/pod2rst\" %(prefix_path)):"," print \"ERROR, %s requires pod2rst, not found in %s/bin/\" %(os.path.basename(__file__), prefix_path)"," parser.print_help()"," sys.exit(1)",""," prefix_lib_path = \"%s/lib\" %(prefix_path)"," if not os.path.isdir(prefix_lib_path):"," prefix_lib_path = \"%s/lib64\" %(prefix_path)"," if not os.path.isdir(prefix_lib_path):"," print \"ERROR, Cannot find the Perl lib directory in %s/lib or %s/lib64\" %(prefix_path, prefix_path)"," sys.exit(1)","","else:"," if not cmd_exists(POD2RST):"," print \"ERROR, %s requires pod2rst to continue!\" %(os.path.basename(__file__))"," parser.print_help()"," sys.exit(1)","","","# the location relativate to xcat-core where the man pages will go","MANPAGE_DEST=\"./docs/source/guides/admin-guides/references/man\"","","#","# add the following to delete the generate files before creating them","# essentially this allows us to remove man pages and they will be","# removed in the generation","print \"Cleaning up the generated man pages in %s\" %(MANPAGE_DEST)","allfiles = glob(\"%s*/*.rst\" %(MANPAGE_DEST))","for d in allfiles:"," # Skip over the index.rst file"," if not \"index.rst\" in d:"," print \"Removing file %s\" %(d)"," os.remove(d)","","# The database man pages are created in the perl-xCAT subdirectory","# using the db2man script","def build_db_man_pages():"," thepwd = os.getcwd()"," os.chdir(\"perl-xCAT\")"," cmd = \"./db2man\""," os.system(cmd)"," os.chdir(thepwd)","","def cleanup_db_man_pages_dir():"," shutil.rmtree(\"perl-xCAT/pods\")"," shutil.rmtree(\"perl-xCAT/share\")","","def fix_vertical_bar(rst_file):"," # Verical bar can not appear with spaces around it, otherwise"," # it gets displayed as a link in .html"," sed_cmd = \"sed 's/\\*\\*\\\\\\ |\\\\\\ \\*\\*/ | /g' %s \u003e %s.sed1\" %(rst_file, rst_file)"," os.system(sed_cmd)","","def fix_double_dash(rst_file):"," # -- gets displayed in .html as a sinle long dash, need to insert"," # a non bold space between 2 dashes"," sed_cmd = \"sed '/\\*\\*/s/--/-\\*\\*\\\\\\ \\*\\*-/g' %s.sed1 \u003e %s\" %(rst_file, rst_file)"," os.system(sed_cmd)"," #remove intermediate .sed1 file"," rm_sed1file_cmd = \"rm %s.sed1\" %(rst_file)"," os.system(rm_sed1file_cmd)","","build_db_man_pages()","","# List the xCAT component directory which contain pod pages","COMPONENTS = ['xCAT-SoftLayer', 'xCAT-test', 'xCAT-client', 'xCAT-vlan', 'perl-xCAT', 'xCAT-buildkit']","","for component in COMPONENTS:"," for root,dirs,files in os.walk(\"%s\" %(component)):",""," for file in files:"," # only interested in .pod files"," if file.endswith(\".pod\"):"," pod_input = os.path.join(root,file)",""," filename = os.path.basename(pod_input)"," # get the man version (1,3,5,8,etc)"," man_ver = filename.split('.')[1]"," # title is needed to pass to pod2rst"," title = filename.split('.')[0]",""," DESTINATION = \"%s%s\" %(MANPAGE_DEST, man_ver)"," try:"," os.stat(DESTINATION)"," except:"," # Create the directory if it does not exist"," os.mkdir(DESTINATION)",""," outputFile = filename.replace(\"pod\", \"rst\")"," rst_output = \"%s/%s\" %(DESTINATION, outputFile)",""," # generate the pod2rst command"," cmd = \"%s\" %(POD2RST)"," if options.PREFIX:"," cmd = \"perl -I %s/share/perl5 %s/bin/%s \" %(prefix_path, prefix_path, POD2RST)",""," cmd += \" --infile=%s --outfile=%s --title=%s.%s\" %(pod_input, rst_output, title, man_ver)"," # print cmd"," os.system(cmd)","\t\tif man_ver == '1' or man_ver == '8':"," fix_vertical_bar(rst_output)"," fix_double_dash(rst_output)","","cleanup_db_man_pages_dir()"],"stylingDirectives":null,"colorizedLines":null,"csv":null,"csvError":null,"dependabotInfo":{"showConfigurationBanner":false,"configFilePath":null,"networkDependabotPath":"/bybai/xcat-core/network/updates","dismissConfigurationNoticePath":"/settings/dismiss-notice/dependabot_configuration_notice","configurationNoticeDismissed":null},"displayName":"create_man_pages.py","displayUrl":"https://github.com/bybai/xcat-core/blob/master/create_man_pages.py?raw=true","headerInfo":{"blobSize":"4.53 KB","deleteTooltip":"You must be signed in to make or propose changes","editTooltip":"You must be signed in to make or propose changes","ghDesktopPath":"https://desktop.github.com","isGitLfs":false,"onBranch":true,"shortPath":"01f24b0","siteNavLoginPath":"/login?return_to=https%3A%2F%2Fgithub.com%2Fbybai%2Fxcat-core%2Fblob%2Fmaster%2Fcreate_man_pages.py","isCSV":false,"isRichtext":false,"toc":null,"lineInfo":{"truncatedLoc":"140","truncatedSloc":"110"},"mode":"executable file"},"image":false,"isCodeownersFile":null,"isPlain":false,"isValidLegacyIssueTemplate":false,"issueTemplate":null,"discussionTemplate":null,"language":"Python","languageID":303,"large":false,"planSupportInfo":{"repoIsFork":null,"repoOwnedByCurrentUser":null,"requestFullPath":"/bybai/xcat-core/blob/master/create_man_pages.py","showFreeOrgGatedFeatureMessage":null,"showPlanSupportBanner":null,"upgradeDataAttributes":null,"upgradePath":null},"publishBannersInfo":{"dismissActionNoticePath":"/settings/dismiss-notice/publish_action_from_dockerfile","releasePath":"/bybai/xcat-core/releases/new?marketplace=true","showPublishActionBanner":false},"rawBlobUrl":"https://github.com/bybai/xcat-core/raw/refs/heads/master/create_man_pages.py","renderImageOrRaw":false,"richText":null,"renderedFileInfo":null,"shortPath":null,"symbolsEnabled":true,"tabSize":8,"topBannersInfo":{"overridingGlobalFundingFile":false,"globalPreferredFundingPath":null,"showInvalidCitationWarning":false,"citationHelpUrl":"https://docs.github.com/github/creating-cloning-and-archiving-repositories/creating-a-repository-on-github/about-citation-files","actionsOnboardingTip":null},"truncated":false,"viewable":true,"workflowRedirectUrl":null,"symbols":null},"copilotInfo":null,"copilotAccessAllowed":false,"modelsAccessAllowed":false,"modelsRepoIntegrationEnabled":false,"csrf_tokens":{"/bybai/xcat-core/branches":{"post":"GvhNsjb8msi283DmhSJH5crTm_HtjoSh_Nc0yRARzsrYSR11rSYrXNPQFmg8niIFLH9Tpw7dPHlYig0Zoezr1Q"},"/repos/preferences":{"post":"CE2XA0ujlyKs_m7_luvgthlC4QO5Moyn5ysWlIYDHs-focteYMAZ1GnpHGYH9R7F3Df1T6-Q4N0lFF8wSgvIrw"}}},"title":"xcat-core/create_man_pages.py at master · bybai/xcat-core","appPayload":{"helpUrl":"https://docs.github.com","findFileWorkerPath":"/assets-cdn/worker/find-file-worker-263cab1760dd.js","findInFileWorkerPath":"/assets-cdn/worker/find-in-file-worker-1b17b3e7786a.js","githubDevUrl":null,"enabled_features":{"code_nav_ui_events":false,"react_blob_overlay":false,"accessible_code_button":true}}}
0