Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / chrome / common / extensions / docs / server2 / link_error_detector.py
index 4598470..ee9bc7c 100644 (file)
@@ -10,14 +10,17 @@ import posixpath
 from urlparse import urlsplit
 
 from file_system_util import CreateURLsFromPaths
-import svn_constants
+from path_util import AssertIsDirectory
+
 
 Page = namedtuple('Page', 'status, links, anchors, anchor_refs')
 
+
 def _SplitAnchor(url):
   components = urlsplit(url)
   return components.path, components.fragment
 
+
 def _Process(path, renderer):
   '''Render the page at |path| using a |renderer| and process the contents of
   that page. Returns a |Page| namedtuple with fields for the http status code
@@ -78,6 +81,7 @@ def _Process(path, renderer):
 
   return Page(200, edges, anchors, anchor_refs)
 
+
 class _ContentParser(HTMLParser):
   '''Parse an html file pulling out all links and anchor_refs, where an
   anchor_ref is a link that contains an anchor.
@@ -106,6 +110,7 @@ class _ContentParser(HTMLParser):
     if attrs.get('name'):
       self.anchors.add(attrs['name'])
 
+
 class LinkErrorDetector(object):
   '''Finds link errors on the doc server. This includes broken links, those with
   a target page that 404s or contain an anchor that doesn't exist, or pages that
@@ -118,6 +123,7 @@ class LinkErrorDetector(object):
     template files. All URLs in |root_pages| are used as the starting nodes for
     the orphaned page search.
     '''
+    AssertIsDirectory(public_path)
     self._file_system = file_system
     self._renderer = renderer
     self._public_path = public_path
@@ -137,9 +143,9 @@ class LinkErrorDetector(object):
     processing the resultant html to pull out all links and anchors.
     '''
     top_level_directories = (
-      (svn_constants.PUBLIC_TEMPLATE_PATH, ''),
-      (svn_constants.STATIC_PATH, 'static/'),
-      (svn_constants.EXAMPLES_PATH, 'extensions/examples/'),
+      ('docs/templates/public/', ''),
+      ('docs/static/', 'static/'),
+      ('docs/examples/', 'extensions/examples/'),
     )
 
     for dirpath, urlprefix in top_level_directories:
@@ -269,6 +275,7 @@ class LinkErrorDetector(object):
 
     return [url for url in all_urls - found if url.endswith('.html')]
 
+
 def StringifyBrokenLinks(broken_links):
   '''Prints out broken links in a more readable format.
   '''