Back to index

python3.2  3.2.2
Functions | Variables
svneol Namespace Reference

Functions

def propfiles
def proplist
def set_eol_native
def main

Variables

tuple possible_text_file = re.compile(r"\.([hc]|py|txt|sln|vcproj)$")

Function Documentation

def svneol.main ( void  )

Definition at line 96 of file svneol.py.

00096 
00097 def main():
00098     for arg in sys.argv[1:] or [os.curdir]:
00099         if os.path.isfile(arg):
00100             root, fn = os.path.split(arg)
00101             if 'svn:eol-style' not in proplist(root, fn):
00102                 set_eol_native(arg)
00103         elif os.path.isdir(arg):
00104             for root, dirs, files in os.walk(arg):
00105                 if '.svn' in dirs:
00106                     dirs.remove('.svn')
00107                 for fn in files:
00108                     if possible_text_file(fn):
00109                         if 'svn:eol-style' not in proplist(root, fn):
00110                             path = os.path.join(root, fn)
00111                             set_eol_native(path)
00112 

Here is the call graph for this function:

def svneol.propfiles (   root,
  fn 
)

Definition at line 39 of file svneol.py.

00039 
00040 def propfiles(root, fn):
00041     default = os.path.join(root, ".svn", "props", fn + ".svn-work")
00042     try:
00043         format = int(open(os.path.join(root, ".svn", "format")).read().strip())
00044     except IOError:
00045         return []
00046     if format in (8, 9):
00047         # In version 8 and 9, committed props are stored in prop-base, local
00048         # modifications in props
00049         return [os.path.join(root, ".svn", "prop-base", fn + ".svn-base"),
00050                 os.path.join(root, ".svn", "props", fn + ".svn-work")]
00051     raise ValueError("Unknown repository format")
00052 

Here is the call graph for this function:

Here is the caller graph for this function:

def svneol.proplist (   root,
  fn 
)
Return a list of property names for file fn in directory root.

Definition at line 53 of file svneol.py.

00053 
00054 def proplist(root, fn):
00055     """Return a list of property names for file fn in directory root."""
00056     result = []
00057     for path in propfiles(root, fn):
00058         try:
00059             f = open(path)
00060         except IOError:
00061             # no properties file: not under version control,
00062             # or no properties set
00063             continue
00064         while True:
00065             # key-value pairs, of the form
00066             # K <length>
00067             # <keyname>NL
00068             # V length
00069             # <value>NL
00070             # END
00071             line = f.readline()
00072             if line.startswith("END"):
00073                 break
00074             assert line.startswith("K ")
00075             L = int(line.split()[1])
00076             key = f.read(L)
00077             result.append(key)
00078             f.readline()
00079             line = f.readline()
00080             assert line.startswith("V ")
00081             L = int(line.split()[1])
00082             value = f.read(L)
00083             f.readline()
00084         f.close()
00085     return result
00086 

Here is the call graph for this function:

Here is the caller graph for this function:

def svneol.set_eol_native (   path)

Definition at line 87 of file svneol.py.

00087 
00088 def set_eol_native(path):
00089     cmd = 'svn propset svn:eol-style native "{}"'.format(path)
00090     propset = subprocess.Popen(cmd, shell=True)
00091     propset.wait()
00092 

Here is the caller graph for this function:


Variable Documentation

tuple svneol.possible_text_file = re.compile(r"\.([hc]|py|txt|sln|vcproj)$")

Definition at line 93 of file svneol.py.