FOP.py 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443
  1. #!/usr/bin/env python3
  2. """ FOP
  3. Filter Orderer and Preener
  4. Copyright (C) 2011 Michael
  5. This program is free software: you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation, either version 3 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program. If not, see <http://www.gnu.org/licenses/>."""
  15. # FOP version number
  16. VERSION = 3.9
  17. # Import the key modules
  18. import collections, filecmp, os, re, subprocess, sys
  19. # Check the version of Python for language compatibility and subprocess.check_output()
  20. MAJORREQUIRED = 3
  21. MINORREQUIRED = 1
  22. if sys.version_info < (MAJORREQUIRED, MINORREQUIRED):
  23. raise RuntimeError("FOP requires Python {reqmajor}.{reqminor} or greater, but Python {ismajor}.{isminor} is being used to run this program.".format(reqmajor = MAJORREQUIRED, reqminor = MINORREQUIRED, ismajor = sys.version_info.major, isminor = sys.version_info.minor))
  24. # Import a module only available in Python 3
  25. from urllib.parse import urlparse
  26. # Compile regular expressions to match important filter parts (derived from Wladimir Palant's Adblock Plus source code)
  27. ELEMENTDOMAINPATTERN = re.compile(r"^([^\/\*\|\@\"\!]*?)#\@?#")
  28. FILTERDOMAINPATTERN = re.compile(r"(?:\$|\,)domain\=([^\,\s]+)$")
  29. ELEMENTPATTERN = re.compile(r"^([^\/\*\|\@\"\!]*?)(#\@?#?)([^{}]+)$")
  30. OPTIONPATTERN = re.compile(r"^(.*)\$(~?[\w\-]+(?:=[^,\s]+)?(?:,~?[\w\-]+(?:=[^,\s]+)?)*)$")
  31. # Compile regular expressions that match element tags and pseudo classes and strings and tree selectors; "@" indicates either the beginning or the end of a selector
  32. SELECTORPATTERN = re.compile(r"(?<=[\s\[@])([a-zA-Z]*[A-Z][a-zA-Z0-9]*)((?=([\[\]\^\*\$=:@#\.]))|(?=(\s(?:[+>~]|\*|[a-zA-Z][a-zA-Z0-9]*[\[:@\s#\.]|[#\.][a-zA-Z][a-zA-Z0-9]*))))")
  33. PSEUDOPATTERN = re.compile(r"(\:[a-zA-Z\-]*[A-Z][a-zA-Z\-]*)(?=([\(\:\@\s]))")
  34. REMOVALPATTERN = re.compile(r"((?<=([>+~,]\s))|(?<=(@|\s|,)))(\*)(?=([#\.\[\:]))")
  35. ATTRIBUTEVALUEPATTERN = re.compile(r"^([^\'\"\\]|\\.)*(\"(?:[^\"\\]|\\.)*\"|\'(?:[^\'\\]|\\.)*\')|\*")
  36. TREESELECTOR = re.compile(r"(\\.|[^\+\>\~\\\ \t])\s*([\+\>\~\ \t])\s*(\D)")
  37. UNICODESELECTOR = re.compile(r"\\[0-9a-fA-F]{1,6}\s[a-zA-Z]*[A-Z]")
  38. # Remove any bad lines less the 3 chars, starting with.. |*~@$%
  39. BADLINE = re.compile(r"^([|*~@$%].{1,3}$)")
  40. # Compile a regular expression that describes a completely blank line
  41. BLANKPATTERN = re.compile(r"^\s*$")
  42. # Compile a regular expression that validates commit comments
  43. COMMITPATTERN = re.compile(r"^(A|M|P)\:\s(\((.+)\)\s)?(.*)$")
  44. # List the files that should not be sorted, either because they have a special sorting system or because they are not filter files
  45. IGNORE = ("CC-BY-SA.txt", "easytest.txt", "GPL.txt", "MPL.txt",
  46. "enhancedstats-addon.txt", "fanboy-tracking", "firefox-regional", "other",
  47. "easylist_cookie_specific_uBO.txt", "fanboy_annoyance_specific_uBO.txt", "fanboy_notifications_specific_uBO.txt", "fanboy_social_specific_uBO.txt")
  48. # List all Adblock Plus options (excepting domain, which is handled separately), as of version 1.3.9
  49. KNOWNOPTIONS = ("collapse", "csp", "document", "elemhide",
  50. "font", "genericblock", "generichide", "image", "match-case",
  51. "object", "media", "object-subrequest", "other", "ping", "popup",
  52. "rewrite=abp-resource:blank-css", "rewrite=abp-resource:blank-js", "rewrite=abp-resource:blank-html", "rewrite=abp-resource:blank-mp3", "rewrite=abp-resource:blank-text",
  53. "rewrite=abp-resource:1x1-transparent-gif", "rewrite=abp-resource:2x2-transparent-png", "rewrite=abp-resource:3x2-transparent-png", "rewrite=abp-resource:32x32-transparent-png",
  54. "script", "stylesheet", "subdocument", "third-party", "websocket", "webrtc", "xmlhttprequest")
  55. # List the supported revision control system commands
  56. REPODEF = collections.namedtuple("repodef", "name, directory, locationoption, repodirectoryoption, checkchanges, difference, commit, pull, push")
  57. GIT = REPODEF(["git"], "./.git/", "--work-tree=", "--git-dir=", ["status", "-s", "--untracked-files=no"], ["diff"], ["commit", "-a", "-m"], ["pull"], ["push"])
  58. HG = REPODEF(["hg"], "./.hg/", "-R", None, ["stat", "-q"], ["diff"], ["commit", "-m"], ["pull"], ["push"])
  59. REPOTYPES = (GIT, HG)
  60. def start ():
  61. """ Print a greeting message and run FOP in the directories
  62. specified via the command line, or the current working directory if
  63. no arguments have been passed."""
  64. greeting = "FOP (Filter Orderer and Preener) version {version}".format(version = VERSION)
  65. characters = len(str(greeting))
  66. print("=" * characters)
  67. print(greeting)
  68. print("=" * characters)
  69. # Convert the directory names to absolute references and visit each unique location
  70. places = sys.argv[1:]
  71. if places:
  72. places = [os.path.abspath(place) for place in places]
  73. for place in sorted(set(places)):
  74. main(place)
  75. print()
  76. else:
  77. main(os.getcwd())
  78. def main (location):
  79. """ Find and sort all the files in a given directory, committing
  80. changes to a repository if one exists."""
  81. # Check that the directory exists, otherwise return
  82. if not os.path.isdir(location):
  83. print("{location} does not exist or is not a folder.".format(location = location))
  84. return
  85. # Set the repository type based on hidden directories
  86. repository = None
  87. for repotype in REPOTYPES:
  88. if os.path.isdir(os.path.join(location, repotype.directory)):
  89. repository = repotype
  90. break
  91. # If this is a repository, record the initial changes; if this fails, give up trying to use the repository
  92. if repository:
  93. try:
  94. basecommand = repository.name
  95. if repository.locationoption.endswith("="):
  96. basecommand.append("{locationoption}{location}".format(locationoption = repository.locationoption, location = location))
  97. else:
  98. basecommand.extend([repository.locationoption, location])
  99. if repository.repodirectoryoption:
  100. if repository.repodirectoryoption.endswith("="):
  101. basecommand.append("{repodirectoryoption}{location}".format(repodirectoryoption = repository.repodirectoryoption, location = os.path.normpath(os.path.join(location, repository.directory))))
  102. else:
  103. basecommand.extend([repository.repodirectoryoption, location])
  104. command = basecommand + repository.checkchanges
  105. originaldifference = True if subprocess.check_output(command) else False
  106. except(subprocess.CalledProcessError, OSError):
  107. print("The command \"{command}\" was unable to run; FOP will therefore not attempt to use the repository tools. On Windows, this may be an indication that you do not have sufficient privileges to run FOP - the exact reason why is unknown. Please also ensure that your revision control system is installed correctly and understood by FOP.".format(command = " ".join(command)))
  108. repository = None
  109. # Work through the directory and any subdirectories, ignoring hidden directories
  110. print("\nPrimary location: {folder}".format(folder = os.path.join(os.path.abspath(location), "")))
  111. for path, directories, files in os.walk(location):
  112. for direct in directories[:]:
  113. if direct.startswith(".") or direct in IGNORE:
  114. directories.remove(direct)
  115. print("Current directory: {folder}".format(folder = os.path.join(os.path.abspath(path), "")))
  116. directories.sort()
  117. for filename in sorted(files):
  118. address = os.path.join(path, filename)
  119. extension = os.path.splitext(filename)[1]
  120. # Sort all text files that are not blacklisted
  121. if extension == ".txt" and filename not in IGNORE:
  122. fopsort(address)
  123. # Delete unnecessary backups and temporary files
  124. if extension == ".orig" or extension == ".temp":
  125. try:
  126. os.remove(address)
  127. except(IOError, OSError):
  128. # Ignore errors resulting from deleting files, as they likely indicate that the file has already been deleted
  129. pass
  130. # If in a repository, offer to commit any changes
  131. if repository:
  132. commit(repository, basecommand, originaldifference)
  133. def fopsort (filename):
  134. """ Sort the sections of the file and save any modifications."""
  135. temporaryfile = "{filename}.temp".format(filename = filename)
  136. CHECKLINES = 10
  137. section = []
  138. lineschecked = 1
  139. filterlines = elementlines = 0
  140. # Read in the input and output files concurrently to allow filters to be saved as soon as they are finished with
  141. with open(filename, "r", encoding = "utf-8", newline = "\n") as inputfile, open(temporaryfile, "w", encoding = "utf-8", newline = "\n") as outputfile:
  142. # Combines domains for (further) identical rules
  143. def combinefilters(uncombinedFilters, DOMAINPATTERN, domainseparator):
  144. combinedFilters = []
  145. for i in range(len(uncombinedFilters)):
  146. domains1 = re.search(DOMAINPATTERN, uncombinedFilters[i])
  147. if i+1 < len(uncombinedFilters) and domains1:
  148. domains2 = re.search(DOMAINPATTERN, uncombinedFilters[i+1])
  149. domain1str = domains1.group(1)
  150. if not domains1 or i+1 == len(uncombinedFilters) or not domains2 or len(domain1str) == 0 or len(domains2.group(1)) == 0:
  151. # last filter or filter didn't match regex or no domains
  152. combinedFilters.append(uncombinedFilters[i])
  153. else:
  154. domain2str = domains2.group(1)
  155. if domains1.group(0).replace(domain1str, domain2str, 1) != domains2.group(0):
  156. # non-identical filters shouldn't be combined
  157. combinedFilters.append(uncombinedFilters[i])
  158. elif re.sub(DOMAINPATTERN, "", uncombinedFilters[i]) == re.sub(DOMAINPATTERN, "", uncombinedFilters[i+1]):
  159. # identical filters. Try to combine them...
  160. newDomains = "{d1}{sep}{d2}".format(d1=domain1str, sep=domainseparator, d2=domain2str)
  161. newDomains = domainseparator.join(sorted(set(newDomains.split(domainseparator)), key = lambda domain: domain.strip("~")))
  162. if (domain1str.count("~") != domain1str.count(domainseparator) + 1) != (domain2str.count("~") != domain2str.count(domainseparator) + 1):
  163. # do not combine rules containing included domains with rules containing only excluded domains
  164. combinedFilters.append(uncombinedFilters[i])
  165. else:
  166. # either both contain one or more included domains, or both contain only excluded domains
  167. domainssubstitute = domains1.group(0).replace(domain1str, newDomains, 1)
  168. uncombinedFilters[i+1] = re.sub(DOMAINPATTERN, domainssubstitute, uncombinedFilters[i])
  169. else:
  170. # non-identical filters shouldn't be combined
  171. combinedFilters.append(uncombinedFilters[i])
  172. return combinedFilters
  173. # Writes the filter lines to the file
  174. def writefilters():
  175. if elementlines > filterlines:
  176. uncombinedFilters = sorted(set(section), key = lambda rule: re.sub(ELEMENTDOMAINPATTERN, "", rule))
  177. outputfile.write("{filters}\n".format(filters = "\n".join(combinefilters(uncombinedFilters, ELEMENTDOMAINPATTERN, ","))))
  178. else:
  179. uncombinedFilters = sorted(set(section), key = str.lower)
  180. outputfile.write("{filters}\n".format(filters = "\n".join(combinefilters(uncombinedFilters, FILTERDOMAINPATTERN, "|"))))
  181. for line in inputfile:
  182. line = line.strip()
  183. if not re.match(BLANKPATTERN, line):
  184. # Include comments verbatim and, if applicable, sort the preceding section of filters and save them in the new version of the file
  185. if line[0] == "!" or line[:8] == "%include" or line[0] == "[" and line[-1] == "]":
  186. if section:
  187. writefilters()
  188. section = []
  189. lineschecked = 1
  190. filterlines = elementlines = 0
  191. outputfile.write("{line}\n".format(line = line))
  192. else:
  193. # Skip filters containing less than three characters
  194. if len(line) < 3:
  195. continue
  196. # Neaten up filters and, if necessary, check their type for the sorting algorithm
  197. elementparts = re.match(ELEMENTPATTERN, line)
  198. if elementparts:
  199. domains = elementparts.group(1).lower()
  200. if lineschecked <= CHECKLINES:
  201. elementlines += 1
  202. lineschecked += 1
  203. line = elementtidy(domains, elementparts.group(2), elementparts.group(3))
  204. else:
  205. if lineschecked <= CHECKLINES:
  206. filterlines += 1
  207. lineschecked += 1
  208. line = filtertidy(line)
  209. # Add the filter to the section
  210. section.append(line)
  211. # At the end of the file, sort and save any remaining filters
  212. if section:
  213. writefilters()
  214. # Replace the existing file with the new one only if alterations have been made
  215. if not filecmp.cmp(temporaryfile, filename):
  216. # Check the operating system and, if it is Windows, delete the old file to avoid an exception (it is not possible to rename files to names already in use on this operating system)
  217. if os.name == "nt":
  218. os.remove(filename)
  219. os.rename(temporaryfile, filename)
  220. print("Sorted: {filename}".format(filename = os.path.abspath(filename)))
  221. else:
  222. os.remove(temporaryfile)
  223. def filtertidy (filterin):
  224. """ Sort the options of blocking filters and make the filter text
  225. lower case if applicable."""
  226. optionsplit = re.match(OPTIONPATTERN, filterin)
  227. if not optionsplit:
  228. # Remove unnecessary asterisks from filters without any options and return them
  229. return removeunnecessarywildcards(filterin)
  230. else:
  231. # If applicable, separate and sort the filter options in addition to the filter text
  232. filtertext = removeunnecessarywildcards(optionsplit.group(1))
  233. optionlist = optionsplit.group(2).lower().replace("_", "-").split(",")
  234. domainlist = []
  235. removeentries = []
  236. for option in optionlist:
  237. # Detect and separate domain options
  238. if option[0:7] == "domain=":
  239. domainlist.extend(option[7:].split("|"))
  240. removeentries.append(option)
  241. elif option.strip("~") not in KNOWNOPTIONS:
  242. print("Warning: The option \"{option}\" used on the filter \"{problemfilter}\" is not recognised by FOP".format(option = option, problemfilter = filterin))
  243. # Sort all options other than domain alphabetically
  244. # For identical options, the inverse always follows the non-inverse option ($image,~image instead of $~image,image)
  245. optionlist = sorted(set(filter(lambda option: option not in removeentries, optionlist)), key = lambda option: (option[1:] + "~") if option[0] == "~" else option)
  246. # If applicable, sort domain restrictions and append them to the list of options
  247. if domainlist:
  248. optionlist.append("domain={domainlist}".format(domainlist = "|".join(sorted(set(filter(lambda domain: domain != "", domainlist)), key = lambda domain: domain.strip("~")))))
  249. # Return the full filter
  250. return "{filtertext}${options}".format(filtertext = filtertext, options = ",".join(optionlist))
  251. def elementtidy (domains, separator, selector):
  252. """ Sort the domains of element hiding rules, remove unnecessary
  253. tags and make the relevant sections of the rule lower case."""
  254. # Order domain names alphabetically, ignoring exceptions
  255. if "," in domains:
  256. domains = ",".join(sorted(set(domains.split(",")), key = lambda domain: domain.strip("~")))
  257. # Mark the beginning and end of the selector with "@"
  258. selector = "@{selector}@".format(selector = selector)
  259. each = re.finditer
  260. # Make sure we don't match items in strings (e.g., don't touch Width in ##[style="height:1px; Width: 123px;"])
  261. selectorwithoutstrings = selector
  262. selectoronlystrings = ""
  263. while True:
  264. stringmatch = re.match(ATTRIBUTEVALUEPATTERN, selectorwithoutstrings)
  265. if stringmatch == None: break
  266. selectorwithoutstrings = selectorwithoutstrings.replace("{before}{stringpart}".format(before = stringmatch.group(1), stringpart = stringmatch.group(2)), "{before}".format(before = stringmatch.group(1)), 1)
  267. selectoronlystrings = "{old}{new}".format(old = selectoronlystrings, new = stringmatch.group(2))
  268. # Clean up tree selectors
  269. for tree in each(TREESELECTOR, selector):
  270. if tree.group(0) in selectoronlystrings or not tree.group(0) in selectorwithoutstrings: continue
  271. replaceby = " {g2} ".format(g2 = tree.group(2))
  272. if replaceby == " ": replaceby = " "
  273. selector = selector.replace(tree.group(0), "{g1}{replaceby}{g3}".format(g1 = tree.group(1), replaceby = replaceby, g3 = tree.group(3)), 1)
  274. # Remove unnecessary tags
  275. for untag in each(REMOVALPATTERN, selector):
  276. untagname = untag.group(4)
  277. if untagname in selectoronlystrings or not untagname in selectorwithoutstrings: continue
  278. bc = untag.group(2)
  279. if bc == None:
  280. bc = untag.group(3)
  281. ac = untag.group(5)
  282. selector = selector.replace("{before}{untag}{after}".format(before = bc, untag = untagname, after = ac), "{before}{after}".format(before = bc, after = ac), 1)
  283. # Make the remaining tags lower case wherever possible
  284. for tag in each(SELECTORPATTERN, selector):
  285. tagname = tag.group(1)
  286. if tagname in selectoronlystrings or not tagname in selectorwithoutstrings: continue
  287. if re.search(UNICODESELECTOR, selectorwithoutstrings) != None: break
  288. ac = tag.group(3)
  289. if ac == None:
  290. ac = tag.group(4)
  291. selector = selector.replace("{tag}{after}".format(tag = tagname, after = ac), "{tag}{after}".format(tag = tagname.lower(), after = ac), 1)
  292. # Make pseudo classes lower case where possible
  293. for pseudo in each(PSEUDOPATTERN, selector):
  294. pseudoclass = pseudo.group(1)
  295. if pseudoclass in selectoronlystrings or not pseudoclass in selectorwithoutstrings: continue
  296. ac = pseudo.group(3)
  297. selector = selector.replace("{pclass}{after}".format(pclass = pseudoclass, after = ac), "{pclass}{after}".format(pclass = pseudoclass.lower(), after = ac), 1)
  298. # Remove the markers from the beginning and end of the selector and return the complete rule
  299. return "{domain}{separator}{selector}".format(domain = domains, separator = separator, selector = selector[1:-1])
  300. def commit (repository, basecommand, userchanges):
  301. """ Commit changes to a repository using the commands provided."""
  302. difference = subprocess.check_output(basecommand + repository.difference)
  303. if not difference:
  304. print("\nNo changes have been recorded by the repository.")
  305. return
  306. print("\nThe following changes have been recorded by the repository:")
  307. try:
  308. print(difference.decode("utf-8"))
  309. except UnicodeEncodeError:
  310. print("\nERROR: DIFF CONTAINED UNKNOWN CHARACTER(S). Showing unformatted diff instead:\n");
  311. print(difference)
  312. try:
  313. # Persistently request a suitable comment
  314. while True:
  315. comment = input("Please enter a valid commit comment or quit:\n")
  316. if checkcomment(comment, userchanges):
  317. break
  318. # Allow users to abort the commit process if they do not approve of the changes
  319. except (KeyboardInterrupt, SystemExit):
  320. print("\nCommit aborted.")
  321. return
  322. print("Comment \"{comment}\" accepted.".format(comment = comment))
  323. try:
  324. # Commit the changes
  325. command = basecommand + repository.commit + [comment]
  326. subprocess.Popen(command).communicate()
  327. print("\nConnecting to server. Please enter your password if required.")
  328. # Update the server repository as required by the revision control system
  329. for command in repository[7:]:
  330. command = basecommand + command
  331. subprocess.Popen(command).communicate()
  332. print()
  333. except(subprocess.CalledProcessError):
  334. print("Unexpected error with the command \"{command}\".".format(command = command))
  335. raise subprocess.CalledProcessError("Aborting FOP.")
  336. except(OSError):
  337. print("Unexpected error with the command \"{command}\".".format(command = command))
  338. raise OSError("Aborting FOP.")
  339. print("Completed commit process successfully.")
  340. def isglobalelement (domains):
  341. """ Check whether all domains are negations."""
  342. for domain in domains.split(","):
  343. if domain and not domain.startswith("~"):
  344. return False
  345. return True
  346. def removeunnecessarywildcards (filtertext):
  347. """ Where possible, remove unnecessary wildcards from the beginnings
  348. and ends of blocking filters."""
  349. allowlist = False
  350. hadStar = False
  351. if filtertext[0:2] == "@@":
  352. allowlist = True
  353. filtertext = filtertext[2:]
  354. while len(filtertext) > 1 and filtertext[0] == "*" and not filtertext[1] == "|" and not filtertext[1] == "!":
  355. filtertext = filtertext[1:]
  356. hadStar = True
  357. while len(filtertext) > 1 and filtertext[-1] == "*" and not filtertext[-2] == "|" and not filtertext[-2] == " ":
  358. filtertext = filtertext[:-1]
  359. hadStar = True
  360. if hadStar and filtertext[0] == "/" and filtertext[-1] == "/":
  361. filtertext = "{filtertext}*".format(filtertext = filtertext)
  362. if filtertext == "*":
  363. filtertext = ""
  364. if allowlist:
  365. filtertext = "@@{filtertext}".format(filtertext = filtertext)
  366. return filtertext
  367. def checkcomment(comment, changed):
  368. """ Check the commit comment and return True if the comment is
  369. acceptable and False if it is not."""
  370. sections = re.match(COMMITPATTERN, comment)
  371. if sections == None:
  372. print("The comment \"{comment}\" is not in the recognised format.".format(comment = comment))
  373. else:
  374. indicator = sections.group(1)
  375. if indicator == "M":
  376. # Allow modification comments to have practically any format
  377. return True
  378. elif indicator == "A" or indicator == "P":
  379. if not changed:
  380. print("You have indicated that you have added or removed a rule, but no changes were initially noted by the repository.")
  381. else:
  382. address = sections.group(4)
  383. if not validurl(address):
  384. print("Unrecognised address \"{address}\".".format(address = address))
  385. else:
  386. # The user has changed the subscription and has written a suitable comment message with a valid address
  387. return True
  388. print()
  389. return False
  390. def validurl (url):
  391. """ Check that an address has a scheme (e.g. http), a domain name
  392. (e.g. example.com) and a path (e.g. /), or relates to the internal
  393. about system."""
  394. addresspart = urlparse(url)
  395. if addresspart.scheme and addresspart.netloc and addresspart.path:
  396. return True
  397. elif addresspart.scheme == "about":
  398. return True
  399. else:
  400. return False
  401. if __name__ == '__main__':
  402. start()