tesseract v5.3.3.20231005
release_docs.WikiBrancher Class Reference
Inheritance diagram for release_docs.WikiBrancher:

Public Member Functions

def __init__ (self, dot_version)
 
def GetFilesToBranch (self)
 
def BranchFiles (self)
 
def UpdateLinksInBranchedFiles (self)
 

Public Attributes

 wiki_dir
 
 version_prefix
 
 files_to_branch
 
 search_for_re
 
 replace_with
 
 project
 

Detailed Description

Branches ...

Definition at line 89 of file release_docs.py.

Constructor & Destructor Documentation

◆ __init__()

def release_docs.WikiBrancher.__init__ (   self,
  dot_version 
)

Definition at line 92 of file release_docs.py.

92 def __init__(self, dot_version):
93 self.project, svn_root_path = common.GetSvnInfo()
94 if self.project not in ('googletest', 'googlemock'):
95 sys.exit('This script must be run in a gtest or gmock SVN workspace.')
96 self.wiki_dir = svn_root_path + '/wiki'
97 # Turn '2.6' to 'V2_6_'.
98 self.version_prefix = 'V' + dot_version.replace('.', '_') + '_'
99 self.files_to_branch = self.GetFilesToBranch()
100 page_names = [DropWikiSuffix(f) for f in self.files_to_branch]
101 # A link to Foo.wiki is in one of the following forms:
102 # [Foo words]
103 # [Foo#Anchor words]
104 # [http://code.google.com/.../wiki/Foo words]
105 # [http://code.google.com/.../wiki/Foo#Anchor words]
106 # We want to replace 'Foo' with 'V2_6_Foo' in the above cases.
107 self.search_for_re = re.compile(
108 # This regex matches either
109 # [Foo
110 # or
111 # /wiki/Foo
112 # followed by a space or a #, where Foo is the name of an
113 # unversioned wiki page.
114 r'(\[|/wiki/)(%s)([ #])' % '|'.join(page_names))
115 self.replace_with = r'\1%s\2\3' % (self.version_prefix,)
116
def GetSvnInfo()
Definition: common.py:55
def DropWikiSuffix(wiki_filename)
Definition: release_docs.py:82

Member Function Documentation

◆ BranchFiles()

def release_docs.WikiBrancher.BranchFiles (   self)
Branches the .wiki files needed to be branched.

Definition at line 127 of file release_docs.py.

127 def BranchFiles(self):
128 """Branches the .wiki files needed to be branched."""
129
130 print 'Branching %d .wiki files:' % (len(self.files_to_branch),)
131 os.chdir(self.wiki_dir)
132 for f in self.files_to_branch:
133 command = 'svn cp %s %s%s' % (f, self.version_prefix, f)
134 print command
135 os.system(command)
136

◆ GetFilesToBranch()

def release_docs.WikiBrancher.GetFilesToBranch (   self)
Returns a list of .wiki file names that need to be branched.

Definition at line 117 of file release_docs.py.

117 def GetFilesToBranch(self):
118 """Returns a list of .wiki file names that need to be branched."""
119
120 unversioned_wikis = (GTEST_UNVERSIONED_WIKIS if self.project == 'googletest'
121 else GMOCK_UNVERSIONED_WIKIS)
122 return [f for f in os.listdir(self.wiki_dir)
123 if (f.endswith('.wiki') and
124 not re.match(r'^V\d', f) and # Excluded versioned .wiki files.
125 f not in unversioned_wikis)]
126

◆ UpdateLinksInBranchedFiles()

def release_docs.WikiBrancher.UpdateLinksInBranchedFiles (   self)

Definition at line 137 of file release_docs.py.

137 def UpdateLinksInBranchedFiles(self):
138
139 for f in self.files_to_branch:
140 source_file = os.path.join(self.wiki_dir, f)
141 versioned_file = os.path.join(self.wiki_dir, self.version_prefix + f)
142 print 'Updating links in %s.' % (versioned_file,)
143 text = file(source_file, 'r').read()
144 new_text = self.search_for_re.sub(self.replace_with, text)
145 file(versioned_file, 'w').write(new_text)
146
147

Member Data Documentation

◆ files_to_branch

release_docs.WikiBrancher.files_to_branch

Definition at line 99 of file release_docs.py.

◆ project

release_docs.WikiBrancher.project

Definition at line 120 of file release_docs.py.

◆ replace_with

release_docs.WikiBrancher.replace_with

Definition at line 115 of file release_docs.py.

◆ search_for_re

release_docs.WikiBrancher.search_for_re

Definition at line 107 of file release_docs.py.

◆ version_prefix

release_docs.WikiBrancher.version_prefix

Definition at line 98 of file release_docs.py.

◆ wiki_dir

release_docs.WikiBrancher.wiki_dir

Definition at line 96 of file release_docs.py.


The documentation for this class was generated from the following file: