PageRenderTime 115ms CodeModel.GetById 40ms RepoModel.GetById 2ms app.codeStats 0ms

/edk2/AppPkg/Applications/Python/Python-2.7.2/Tools/faqwiz/faqconf.py

https://gitlab.com/envieidoc/Clover
Python | 577 lines | 543 code | 4 blank | 30 comment | 0 complexity | 9435497732119a930505160874966d66 MD5 | raw file
  1. """FAQ Wizard customization module.
  2. Edit this file to customize the FAQ Wizard. For normal purposes, you
  3. should only have to change the FAQ section titles and the small group
  4. of parameters below it.
  5. """
  6. # Titles of FAQ sections
  7. SECTION_TITLES = {
  8. # SectionNumber : SectionTitle; need at least one entry
  9. 1: "General information and availability",
  10. }
  11. # Parameters you definitely want to change
  12. SHORTNAME = "Generic" # FAQ name with "FAQ" omitted
  13. PASSWORD = "" # Password for editing
  14. OWNERNAME = "FAQ owner" # Name for feedback
  15. OWNEREMAIL = "nobody@anywhere.org" # Email for feedback
  16. HOMEURL = "http://www.python.org" # Related home page
  17. HOMENAME = "Python home" # Name of related home page
  18. RCSBINDIR = "/usr/local/bin/" # Directory containing RCS commands
  19. # (must end in a slash)
  20. # Parameters you can normally leave alone
  21. MAXHITS = 10 # Max #hits to be shown directly
  22. COOKIE_LIFETIME = 28*24*3600 # Cookie expiration in seconds
  23. # (28*24*3600 = 28 days = 4 weeks)
  24. PROCESS_PREFORMAT = 1 # toggle whether preformatted text
  25. # will replace urls and emails with
  26. # HTML links
  27. # Markers appended to title to indicate recently change
  28. # (may contain HTML, e.g. <IMG>); and corresponding
  29. MARK_VERY_RECENT = " **" # Changed very recently
  30. MARK_RECENT = " *" # Changed recently
  31. DT_VERY_RECENT = 24*3600 # 24 hours
  32. DT_RECENT = 7*24*3600 # 7 days
  33. EXPLAIN_MARKS = """
  34. <P>(Entries marked with ** were changed within the last 24 hours;
  35. entries marked with * were changed within the last 7 days.)
  36. <P>
  37. """
  38. # Version -- don't change unless you edit faqwiz.py
  39. WIZVERSION = "1.0.4" # FAQ Wizard version
  40. import os, sys
  41. if os.name in ['nt',]:
  42. # On NT we'll probably be running python from a batch file,
  43. # so sys.argv[0] is not helpful
  44. FAQCGI = 'faq.bat' # Relative URL of the FAQ cgi script
  45. # LOGNAME is not typically set on NT
  46. os.environ[ 'LOGNAME' ] = "FAQWizard"
  47. else:
  48. # This parameter is normally overwritten with a dynamic value
  49. FAQCGI = 'faqw.py' # Relative URL of the FAQ cgi script
  50. FAQCGI = os.path.basename(sys.argv[0]) or FAQCGI
  51. del os, sys
  52. # Perl (re module) style regular expression to recognize FAQ entry
  53. # files: group(1) should be the section number, group(2) should be the
  54. # question number. Both should be fixed width so simple-minded
  55. # sorting yields the right order.
  56. OKFILENAME = r"^faq(\d\d)\.(\d\d\d)\.htp$"
  57. # Format to construct a FAQ entry file name
  58. NEWFILENAME = "faq%02d.%03d.htp"
  59. # Load local customizations on top of the previous parameters
  60. try:
  61. from faqcust import *
  62. except ImportError:
  63. pass
  64. # Calculated parameter names
  65. COOKIE_NAME = SHORTNAME + "-FAQ-Wizard" # Name used for Netscape cookie
  66. FAQNAME = SHORTNAME + " FAQ" # Name of the FAQ
  67. # ----------------------------------------------------------------------
  68. # Anything below this point normally needn't be changed; you would
  69. # change this if you were to create e.g. a French translation or if
  70. # you just aren't happy with the text generated by the FAQ Wizard.
  71. # Most strings here are subject to substitution (string%dictionary)
  72. # RCS commands
  73. import os
  74. if os.name in ['nt', ]:
  75. SH_RLOG = RCSBINDIR + "rlog %(file)s < NUL"
  76. SH_RLOG_H = RCSBINDIR + "rlog -h %(file)s < NUL"
  77. SH_RDIFF = RCSBINDIR + "rcsdiff -r%(prev)s -r%(rev)s %(file)s < NUL"
  78. SH_REVISION = RCSBINDIR + "co -p%(rev)s %(file)s < NUL"
  79. ### Have to use co -l, or the file is not marked rw on NT
  80. SH_LOCK = RCSBINDIR + "co -l %(file)s < NUL"
  81. SH_CHECKIN = RCSBINDIR + "ci -u %(file)s < %(tfn)s"
  82. else:
  83. SH_RLOG = RCSBINDIR + "rlog %(file)s </dev/null 2>&1"
  84. SH_RLOG_H = RCSBINDIR + "rlog -h %(file)s </dev/null 2>&1"
  85. SH_RDIFF = RCSBINDIR + "rcsdiff -r%(prev)s -r%(rev)s %(file)s </dev/null 2>&1"
  86. SH_REVISION = RCSBINDIR + "co -p%(rev)s %(file)s </dev/null 2>&1"
  87. SH_LOCK = RCSBINDIR + "rcs -l %(file)s </dev/null 2>&1"
  88. SH_CHECKIN = RCSBINDIR + "ci -u %(file)s <%(tfn)s 2>&1"
  89. del os
  90. # Titles for various output pages (not subject to substitution)
  91. T_HOME = FAQNAME + " Wizard " + WIZVERSION
  92. T_ERROR = "Sorry, an error occurred"
  93. T_ROULETTE = FAQNAME + " Roulette"
  94. T_ALL = "The Whole " + FAQNAME
  95. T_INDEX = FAQNAME + " Index"
  96. T_SEARCH = FAQNAME + " Search Results"
  97. T_RECENT = "What's New in the " + FAQNAME
  98. T_SHOW = FAQNAME + " Entry"
  99. T_LOG = "RCS log for %s entry" % FAQNAME
  100. T_REVISION = "RCS revision for %s entry" % FAQNAME
  101. T_DIFF = "RCS diff for %s entry" % FAQNAME
  102. T_ADD = "Add an entry to the " + FAQNAME
  103. T_DELETE = "Deleting an entry from the " + FAQNAME
  104. T_EDIT = FAQNAME + " Edit Wizard"
  105. T_REVIEW = T_EDIT + " - Review Changes"
  106. T_COMMITTED = T_EDIT + " - Changes Committed"
  107. T_COMMITFAILED = T_EDIT + " - Commit Failed"
  108. T_CANTCOMMIT = T_EDIT + " - Commit Rejected"
  109. T_HELP = T_EDIT + " - Help"
  110. # Generic prologue and epilogue
  111. PROLOGUE = '''
  112. <HTML>
  113. <HEAD>
  114. <TITLE>%(title)s</TITLE>
  115. </HEAD>
  116. <BODY
  117. BGCOLOR="#FFFFFF"
  118. TEXT="#000000"
  119. LINK="#AA0000"
  120. VLINK="#906A6A">
  121. <H1>%(title)s</H1>
  122. '''
  123. EPILOGUE = '''
  124. <HR>
  125. <A HREF="%(HOMEURL)s">%(HOMENAME)s</A> /
  126. <A HREF="%(FAQCGI)s?req=home">%(FAQNAME)s Wizard %(WIZVERSION)s</A> /
  127. Feedback to <A HREF="mailto:%(OWNEREMAIL)s">%(OWNERNAME)s</A>
  128. </BODY>
  129. </HTML>
  130. '''
  131. # Home page
  132. HOME = """
  133. <H2>Search the %(FAQNAME)s:</H2>
  134. <BLOCKQUOTE>
  135. <FORM ACTION="%(FAQCGI)s">
  136. <INPUT TYPE=text NAME=query>
  137. <INPUT TYPE=submit VALUE="Search"><BR>
  138. <INPUT TYPE=radio NAME=querytype VALUE=simple CHECKED>
  139. Simple string
  140. /
  141. <INPUT TYPE=radio NAME=querytype VALUE=regex>
  142. Regular expression
  143. /<BR>
  144. <INPUT TYPE=radio NAME=querytype VALUE=anykeywords>
  145. Keywords (any)
  146. /
  147. <INPUT TYPE=radio NAME=querytype VALUE=allkeywords>
  148. Keywords (all)
  149. <BR>
  150. <INPUT TYPE=radio NAME=casefold VALUE=yes CHECKED>
  151. Fold case
  152. /
  153. <INPUT TYPE=radio NAME=casefold VALUE=no>
  154. Case sensitive
  155. <BR>
  156. <INPUT TYPE=hidden NAME=req VALUE=search>
  157. </FORM>
  158. </BLOCKQUOTE>
  159. <HR>
  160. <H2>Other forms of %(FAQNAME)s access:</H2>
  161. <UL>
  162. <LI><A HREF="%(FAQCGI)s?req=index">FAQ index</A>
  163. <LI><A HREF="%(FAQCGI)s?req=all">The whole FAQ</A>
  164. <LI><A HREF="%(FAQCGI)s?req=recent">What's new in the FAQ?</A>
  165. <LI><A HREF="%(FAQCGI)s?req=roulette">FAQ roulette</A>
  166. <LI><A HREF="%(FAQCGI)s?req=add">Add a FAQ entry</A>
  167. <LI><A HREF="%(FAQCGI)s?req=delete">Delete a FAQ entry</A>
  168. </UL>
  169. """
  170. # Index formatting
  171. INDEX_SECTION = """
  172. <P>
  173. <HR>
  174. <H2>%(sec)s. %(title)s</H2>
  175. <UL>
  176. """
  177. INDEX_ADDSECTION = """
  178. <P>
  179. <LI><A HREF="%(FAQCGI)s?req=new&amp;section=%(sec)s">Add new entry</A>
  180. (at this point)
  181. """
  182. INDEX_ENDSECTION = """
  183. </UL>
  184. """
  185. INDEX_ENTRY = """\
  186. <LI><A HREF="%(FAQCGI)s?req=show&amp;file=%(file)s">%(title)s</A>
  187. """
  188. LOCAL_ENTRY = """\
  189. <LI><A HREF="#%(sec)s.%(num)s">%(title)s</A>
  190. """
  191. # Entry formatting
  192. ENTRY_HEADER1 = """
  193. <HR>
  194. <H2><A NAME="%(sec)s.%(num)s">%(title)s</A>\
  195. """
  196. ENTRY_HEADER2 = """\
  197. </H2>
  198. """
  199. ENTRY_FOOTER = """
  200. <A HREF="%(FAQCGI)s?req=edit&amp;file=%(file)s">Edit this entry</A> /
  201. <A HREF="%(FAQCGI)s?req=log&amp;file=%(file)s">Log info</A>
  202. """
  203. ENTRY_LOGINFO = """
  204. / Last changed on %(last_changed_date)s by
  205. <A HREF="mailto:%(last_changed_email)s">%(last_changed_author)s</A>
  206. """
  207. # Search
  208. NO_HITS = """
  209. No hits.
  210. """
  211. ONE_HIT = """
  212. Your search matched the following entry:
  213. """
  214. FEW_HITS = """
  215. Your search matched the following %(count)s entries:
  216. """
  217. MANY_HITS = """
  218. Your search matched more than %(MAXHITS)s entries.
  219. The %(count)s matching entries are presented here ordered by section:
  220. """
  221. # RCS log and diff
  222. LOG = """
  223. Click on a revision line to see the diff between that revision and the
  224. previous one.
  225. """
  226. REVISIONLINK = """\
  227. <A HREF="%(FAQCGI)s?req=revision&amp;file=%(file)s&amp;rev=%(rev)s"
  228. >%(line)s</A>\
  229. """
  230. DIFFLINK = """\
  231. (<A HREF="%(FAQCGI)s?req=diff&amp;file=%(file)s&amp;\
  232. prev=%(prev)s&amp;rev=%(rev)s"
  233. >diff -r%(prev)s -r%(rev)s</A>)\
  234. """
  235. # Recently changed entries
  236. NO_RECENT = """
  237. <HR>
  238. No %(FAQNAME)s entries were changed in the last %(period)s.
  239. """
  240. VIEW_MENU = """
  241. <HR>
  242. View entries changed in the last...
  243. <UL>
  244. <LI><A HREF="%(FAQCGI)s?req=recent&amp;days=1">24 hours</A>
  245. <LI><A HREF="%(FAQCGI)s?req=recent&amp;days=2">2 days</A>
  246. <LI><A HREF="%(FAQCGI)s?req=recent&amp;days=3">3 days</A>
  247. <LI><A HREF="%(FAQCGI)s?req=recent&amp;days=7">week</A>
  248. <LI><A HREF="%(FAQCGI)s?req=recent&amp;days=28">4 weeks</A>
  249. <LI><A HREF="%(FAQCGI)s?req=recent&amp;days=365250">millennium</A>
  250. </UL>
  251. """
  252. ONE_RECENT = VIEW_MENU + """
  253. The following %(FAQNAME)s entry was changed in the last %(period)s:
  254. """
  255. SOME_RECENT = VIEW_MENU + """
  256. The following %(count)s %(FAQNAME)s entries were changed
  257. in the last %(period)s, most recently changed shown first:
  258. """
  259. TAIL_RECENT = VIEW_MENU
  260. # Last changed banner on "all" (strftime format)
  261. LAST_CHANGED = "Last changed on %c %Z"
  262. # "Compat" command prologue (this has no <BODY> tag)
  263. COMPAT = """
  264. <H1>The whole %(FAQNAME)s</H1>
  265. See also the <A HREF="%(FAQCGI)s?req=home">%(FAQNAME)s Wizard</A>.
  266. <P>
  267. """
  268. # Editing
  269. EDITHEAD = """
  270. <A HREF="%(FAQCGI)s?req=help">Click for Help</A>
  271. """
  272. REVIEWHEAD = EDITHEAD
  273. EDITFORM1 = """
  274. <FORM ACTION="%(FAQCGI)s" METHOD=POST>
  275. <INPUT TYPE=hidden NAME=req VALUE=review>
  276. <INPUT TYPE=hidden NAME=file VALUE=%(file)s>
  277. <INPUT TYPE=hidden NAME=editversion VALUE=%(editversion)s>
  278. <HR>
  279. """
  280. EDITFORM2 = """
  281. Title: <INPUT TYPE=text SIZE=70 NAME=title VALUE="%(title)s"><BR>
  282. <TEXTAREA COLS=72 ROWS=20 NAME=body>%(body)s
  283. </TEXTAREA><BR>
  284. Log message (reason for the change):<BR>
  285. <TEXTAREA COLS=72 ROWS=5 NAME=log>%(log)s
  286. </TEXTAREA><BR>
  287. Please provide the following information for logging purposes:
  288. <TABLE FRAME=none COLS=2>
  289. <TR>
  290. <TD>Name:
  291. <TD><INPUT TYPE=text SIZE=40 NAME=author VALUE="%(author)s">
  292. <TR>
  293. <TD>Email:
  294. <TD><INPUT TYPE=text SIZE=40 NAME=email VALUE="%(email)s">
  295. <TR>
  296. <TD>Password:
  297. <TD><INPUT TYPE=password SIZE=20 NAME=password VALUE="%(password)s">
  298. </TABLE>
  299. <INPUT TYPE=submit NAME=review VALUE="Preview Edit">
  300. Click this button to preview your changes.
  301. """
  302. EDITFORM3 = """
  303. </FORM>
  304. """
  305. COMMIT = """
  306. <INPUT TYPE=submit NAME=commit VALUE="Commit">
  307. Click this button to commit your changes.
  308. <HR>
  309. """
  310. NOCOMMIT_HEAD = """
  311. To commit your changes, please correct the following errors in the
  312. form below and click the Preview Edit button.
  313. <UL>
  314. """
  315. NOCOMMIT_TAIL = """
  316. </UL>
  317. <HR>
  318. """
  319. CANTCOMMIT_HEAD = """
  320. Some required information is missing:
  321. <UL>
  322. """
  323. NEED_PASSWD = "<LI>You must provide the correct password.\n"
  324. NEED_AUTHOR = "<LI>You must enter your name.\n"
  325. NEED_EMAIL = "<LI>You must enter your email address.\n"
  326. NEED_LOG = "<LI>You must enter a log message.\n"
  327. CANTCOMMIT_TAIL = """
  328. </UL>
  329. Please use your browser's Back command to correct the form and commit
  330. again.
  331. """
  332. NEWCONFLICT = """
  333. <P>
  334. You are creating a new entry, but the entry number specified is not
  335. correct.
  336. <P>
  337. The two most common causes of this problem are:
  338. <UL>
  339. <LI>After creating the entry yourself, you went back in your browser,
  340. edited the entry some more, and clicked Commit again.
  341. <LI>Someone else started creating a new entry in the same section and
  342. committed before you did.
  343. </UL>
  344. (It is also possible that the last entry in the section was physically
  345. deleted, but this should not happen except through manual intervention
  346. by the FAQ maintainer.)
  347. <P>
  348. <A HREF="%(FAQCGI)s?req=new&amp;section=%(sec)s">Click here to try
  349. again.</A>
  350. <P>
  351. """
  352. VERSIONCONFLICT = """
  353. <P>
  354. You edited version %(editversion)s but the current version is %(version)s.
  355. <P>
  356. The two most common causes of this problem are:
  357. <UL>
  358. <LI>After committing a change, you went back in your browser,
  359. edited the entry some more, and clicked Commit again.
  360. <LI>Someone else started editing the same entry and committed
  361. before you did.
  362. </UL>
  363. <P>
  364. <A HREF="%(FAQCGI)s?req=show&amp;file=%(file)s">Click here to reload
  365. the entry and try again.</A>
  366. <P>
  367. """
  368. CANTWRITE = """
  369. Can't write file %(file)s (%(why)s).
  370. """
  371. FILEHEADER = """\
  372. Title: %(title)s
  373. Last-Changed-Date: %(date)s
  374. Last-Changed-Author: %(author)s
  375. Last-Changed-Email: %(email)s
  376. Last-Changed-Remote-Host: %(REMOTE_HOST)s
  377. Last-Changed-Remote-Address: %(REMOTE_ADDR)s
  378. """
  379. LOGHEADER = """\
  380. Last-Changed-Date: %(date)s
  381. Last-Changed-Author: %(author)s
  382. Last-Changed-Email: %(email)s
  383. Last-Changed-Remote-Host: %(REMOTE_HOST)s
  384. Last-Changed-Remote-Address: %(REMOTE_ADDR)s
  385. %(log)s
  386. """
  387. COMMITTED = """
  388. Your changes have been committed.
  389. """
  390. COMMITFAILED = """
  391. Exit status %(sts)s.
  392. """
  393. # Add/Delete
  394. ADD_HEAD = """
  395. At the moment, new entries can only be added at the end of a section.
  396. This is because the entry numbers are also their
  397. unique identifiers -- it's a bad idea to renumber entries.
  398. <P>
  399. Click on the section to which you want to add a new entry:
  400. <UL>
  401. """
  402. ADD_SECTION = """\
  403. <LI><A HREF="%(FAQCGI)s?req=new&amp;section=%(section)s">%(section)s. %(title)s</A>
  404. """
  405. ADD_TAIL = """
  406. </UL>
  407. """
  408. ROULETTE = """
  409. <P>Hit your browser's Reload button to play again.<P>
  410. """
  411. DELETE = """
  412. At the moment, there's no direct way to delete entries.
  413. This is because the entry numbers are also their
  414. unique identifiers -- it's a bad idea to renumber entries.
  415. <P>
  416. If you really think an entry needs to be deleted,
  417. change the title to "(deleted)" and make the body
  418. empty (keep the entry number in the title though).
  419. """
  420. # Help file for the FAQ Edit Wizard
  421. HELP = """
  422. Using the %(FAQNAME)s Edit Wizard speaks mostly for itself. Here are
  423. some answers to questions you are likely to ask:
  424. <P><HR>
  425. <H2>I can review an entry but I can't commit it.</H2>
  426. The commit button only appears if the following conditions are met:
  427. <UL>
  428. <LI>The Name field is not empty.
  429. <LI>The Email field contains at least an @ character.
  430. <LI>The Log message box is not empty.
  431. <LI>The Password field contains the proper password.
  432. </UL>
  433. <P><HR>
  434. <H2>What is the password?</H2>
  435. At the moment, only PSA members will be told the password. This is a
  436. good time to join the PSA! See <A
  437. HREF="http://www.python.org/psa/">the PSA home page</A>.
  438. <P><HR>
  439. <H2>Can I use HTML in the FAQ entry?</H2>
  440. Yes, if you include it in &lt;HTML&rt; and &lt;/HTML&gt; tags.
  441. <P>
  442. Also, if you include a URL or an email address in the text it will
  443. automatigally become an anchor of the right type. Also, *word*
  444. is made italic (but only for single alphabetic words).
  445. <P><HR>
  446. <H2>How do I delineate paragraphs?</H2>
  447. Use blank lines to separate paragraphs.
  448. <P><HR>
  449. <H2>How do I enter example text?</H2>
  450. Any line that begins with a space or tab is assumed to be part of
  451. literal text. Blocks of literal text delineated by blank lines are
  452. placed inside &lt;PRE&gt;...&lt;/PRE&gt;.
  453. """
  454. # Load local customizations again, in case they set some other variables
  455. try:
  456. from faqcust import *
  457. except ImportError:
  458. pass