[Zope-CVS] CVS: Products/Ape/lib/apelib/fs - annotated.py:1.6 base.py:1.9 classification.py:1.6 connection.py:1.10 interfaces.py:1.6 oidtable.py:1.3 params.py:1.3 properties.py:1.6 security.py:1.5 structure.py:1.10

Shane Hathaway shane at zope.com
Sat Mar 20 01:34:54 EST 2004


Update of /cvs-repository/Products/Ape/lib/apelib/fs
In directory cvs.zope.org:/tmp/cvs-serv19743/lib/apelib/fs

Modified Files:
	annotated.py base.py classification.py connection.py 
	interfaces.py oidtable.py params.py properties.py security.py 
	structure.py 
Log Message:
Converted method and function names to conform with PEP 8.

PEP 8 (or perhaps the next revision) recommends 
lowercase_with_underscores over mixedCase.  Since everything is being 
renamed for this release anyway, why not throw in this too? :-)

Also got SQLMultiTableProperties back into shape.



=== Products/Ape/lib/apelib/fs/annotated.py 1.5 => 1.6 ===
--- Products/Ape/lib/apelib/fs/annotated.py:1.5	Sat Feb 28 15:06:27 2004
+++ Products/Ape/lib/apelib/fs/annotated.py	Sat Mar 20 01:34:23 2004
@@ -53,7 +53,7 @@
         # _dir_cache: { path -> directory info }
         self._dir_cache = ShortLivedCache()
 
-    def clearCache(self):
+    def clear_cache(self):
         """Clears the cache of annotations and automatic filename extensions.
 
         Useful after writing to the filesystem.
@@ -67,7 +67,7 @@
         self._anns_cache.invalidate(path)
         self._dir_cache.invalidate(path)
 
-    def getAnnotationPaths(self, path):
+    def get_annotation_paths(self, path):
         """Returns the property and remainder paths for a path.
         """
         ops = self.ops
@@ -79,12 +79,12 @@
                 self.annotation_prefix, filename))
         return (base_fn + properties_ext, base_fn + remainder_ext)
 
-    def getAnnotations(self, path):
+    def get_annotations(self, path):
         """Reads the annotations for a path."""
         res = self._anns_cache.get(path)
         if res is not None:
             return res
-        props_fn, rem_fn = self.getAnnotationPaths(path)
+        props_fn, rem_fn = self.get_annotation_paths(path)
         res = {}
         try:
             data = self.ops.readfile(rem_fn, 0)
@@ -120,7 +120,7 @@
         self._anns_cache.set(path, res)
         return res
 
-    def checkAnnotationName(self, ann_name):
+    def check_annotation_name(self, ann_name):
         if (not isinstance(ann_name, StringType)
             or not ann_name
             or '[' in ann_name
@@ -128,31 +128,28 @@
             or '\n' in ann_name):
             raise ValueError(ann_name)
 
-    def writeAnnotations(self, path, anns):
-        props_fn, rem_fn = self.getAnnotationPaths(path)
+    def write_annotations(self, path, anns):
+        props_fn, rem_fn = self.get_annotation_paths(path)
         props_data = ''
         rem_data = ''
         items = anns.items()
         items.sort()
         for name, value in items:
             # Write a section of the properties file.
-            props_data += self.formatSection(name, value)
-        self.writeOrRemove(props_fn, 1, props_data)
-        # XXX Now that the remainder is folded into the properties
-        # file, writeOrRemove() no longer needs to be a separate
-        # method.
-        self.writeOrRemove(rem_fn, 0, rem_data)
+            props_data += self._format_section(name, value)
+        self._write_or_remove(props_fn, 1, props_data)
+        self._write_or_remove(rem_fn, 0, rem_data)
         self._anns_cache.invalidate(path)
         # The file might be new, so invalidate the directory.
         self._dir_cache.invalidate(self.ops.dirname(path))
 
-    def formatSection(self, name, text):
+    def _format_section(self, name, text):
         s = '[%s]\n%s\n' % (name, text.replace('[', '[['))
         if not text.endswith('\n'):
             s += '\n'
         return s
 
-    def writeOrRemove(self, fn, as_text, data):
+    def _write_or_remove(self, fn, as_text, data):
         """If data is provided, write it.  Otherwise remove the file.
         """
         ops = self.ops
@@ -162,7 +159,7 @@
             if ops.exists(fn):
                 ops.remove(fn)
 
-    def isLegalFilename(self, fn):
+    def is_legal_filename(self, fn):
         ap = self.annotation_prefix
         if (not fn or
             (fn.startswith(ap) and annotation_re.match(fn, len(ap)))
@@ -170,7 +167,7 @@
             return 0
         return 1
 
-    def computeContents(self, path, allow_missing=0):
+    def compute_contents(self, path, allow_missing=0):
         """Returns the name translations for a directory.  Caches the results.
 
         Returns ({filename: name}, {name: filename}).
@@ -188,8 +185,8 @@
         
         obj_list = []   # [name]
         trans = {}     # { base name -> filename with extension or None }
-        filenames = filter(self.isLegalFilename, fns)
-        anns = self.getAnnotations(path)
+        filenames = filter(self.is_legal_filename, fns)
+        anns = self.get_annotations(path)
         text = anns.get(object_names_ann)
         if text:
             # Prepare a dictionary of translations from basename to filename.


=== Products/Ape/lib/apelib/fs/base.py 1.8 => 1.9 ===
--- Products/Ape/lib/apelib/fs/base.py:1.8	Sat Feb 28 15:06:27 2004
+++ Products/Ape/lib/apelib/fs/base.py	Sat Mar 20 01:34:23 2004
@@ -24,8 +24,8 @@
     def __init__(self, conn_name='fs'):
         self.conn_name = conn_name
 
-    def getConnection(self, event):
+    def get_connection(self, event):
         return event.connections[self.conn_name]
 
-    def getPollSources(self, event):
+    def get_sources(self, event):
         return None


=== Products/Ape/lib/apelib/fs/classification.py 1.5 => 1.6 ===
--- Products/Ape/lib/apelib/fs/classification.py:1.5	Sat Feb 28 15:06:27 2004
+++ Products/Ape/lib/apelib/fs/classification.py	Sat Mar 20 01:34:23 2004
@@ -30,28 +30,28 @@
     schema = FieldSchema('classification', 'classification')
 
     def load(self, event):
-        fs_conn = self.getConnection(event)
+        fs_conn = self.get_connection(event)
         oid = event.oid
-        classification = {'node_type': fs_conn.readNodeType(oid)}
-        text = fs_conn.readAnnotation(oid, 'classification', '')
+        classification = {'node_type': fs_conn.read_node_type(oid)}
+        text = fs_conn.read_annotation(oid, 'classification', '')
         if text:
             lines = text.split('\n')
             for line in lines:
                 if '=' in line:
                     k, v = line.split('=', 1)
                     classification[k.strip()] = v.strip()
-        classification['extension'] = fs_conn.getExtension(oid)
-        classification['subpath'] = fs_conn.getSubpath(oid)
+        classification['extension'] = fs_conn.read_extension(oid)
+        classification['subpath'] = fs_conn.get_subpath(oid)
         return classification, text.strip()
 
     def store(self, event, state):
         # state is a classification
-        fs_conn = self.getConnection(event)
+        fs_conn = self.get_connection(event)
         oid = event.oid
         if event.is_new:
             # Don't overwrite existing data
             try:
-                fs_conn.readNodeType(oid)
+                fs_conn.read_node_type(oid)
             except LoadError:
                 # Nothing exists yet.
                 pass
@@ -63,9 +63,9 @@
         text = []
         for k, v in items:
             if k == 'extension':
-                fs_conn.suggestExtension(oid, v)
+                fs_conn.suggest_extension(oid, v)
             else:
                 text.append('%s=%s' % (k, v))
         text = '\n'.join(text)
-        fs_conn.writeAnnotation(oid, 'classification', text)
+        fs_conn.write_annotation(oid, 'classification', text)
         return text.strip()


=== Products/Ape/lib/apelib/fs/connection.py 1.9 => 1.10 ===
--- Products/Ape/lib/apelib/fs/connection.py:1.9	Wed Mar 17 20:05:11 2004
+++ Products/Ape/lib/apelib/fs/connection.py	Sat Mar 20 01:34:23 2004
@@ -74,7 +74,7 @@
     def reset(self):
         self._final = 0
         self._pending.clear()
-        self.afs.clearCache()
+        self.afs.clear_cache()
         self._script = None
         self._tmp_subpaths.clear()
 
@@ -82,8 +82,8 @@
     # IFSReader implementation.
     #
 
-    def getSubpath(self, oid):
-        p = self.table.getPath(self.root_oid, oid)
+    def get_subpath(self, oid):
+        p = self.table.get_path(self.root_oid, oid)
         if p is None:
             return self._tmp_subpaths.get(oid)
         if self.app_filename:
@@ -97,34 +97,34 @@
         else:
             return p
 
-    def getPath(self, oid):
-        p = self.getSubpath(oid)
+    def get_path(self, oid):
+        p = self.get_subpath(oid)
         if p is None:
             raise LoadError(oid)
         return self.ops.join(self.basepath, *p)
 
-    def readNodeType(self, oid):
-        path = self.getPath(oid)
+    def read_node_type(self, oid):
+        path = self.get_path(oid)
         if not self.ops.exists(path):
             raise LoadError("%s does not exist" % path)
         return self.ops.isdir(path) and 'd' or 'f'
 
-    def readData(self, oid, allow_missing=0, as_text=0):
+    def read_data(self, oid, allow_missing=0, as_text=0):
         # Return a string.
         try:
-            path = self.getPath(oid)
+            path = self.get_path(oid)
             return self.ops.readfile(path, as_text)
         except (LoadError, IOError):
             if allow_missing:
                 return None
             raise
 
-    def readDirectory(self, oid, allow_missing=0):
+    def read_directory(self, oid, allow_missing=0):
         # Return a sequence of (object_name, child_oid).
-        path = self.getPath(oid)
-        contents = self.afs.computeContents(path, allow_missing)
+        path = self.get_path(oid)
+        contents = self.afs.compute_contents(path, allow_missing)
         fn_to_name, name_to_fn = contents
-        children = self.table.getChildren(oid)
+        children = self.table.get_children(oid)
         if children is None:
             children = {}
         # Remove vanished children from the OID table.
@@ -136,47 +136,47 @@
         return [(objname, children.get(filename))
                 for filename, objname in fn_to_name.items()]
 
-    def readAnnotation(self, oid, name, default=None):
-        path = self.getPath(oid)
-        annotations = self.afs.getAnnotations(path)
+    def read_annotation(self, oid, name, default=None):
+        path = self.get_path(oid)
+        annotations = self.afs.get_annotations(path)
         return annotations.get(name, default)
 
-    def readObjectName(self, oid):
-        parents = self.table.getParents(oid)
+    def read_object_name(self, oid):
+        parents = self.table.get_parents(oid)
         parent_oid, filename = parents[0]
-        parent_path = self.getPath(parent_oid)
-        contents = self.afs.computeContents(parent_path)
+        parent_path = self.get_path(parent_oid)
+        contents = self.afs.compute_contents(parent_path)
         fn_to_name, name_to_fn = contents
         return fn_to_name[filename]
 
-    def getExtension(self, oid):
-        path = self.getPath(oid)
+    def read_extension(self, oid):
+        path = self.get_path(oid)
         stuff, ext = self.ops.splitext(path)
         return ext
 
-    def assignExisting(self, oid, children):
+    def assign_existing(self, oid, children):
         """See IFSReader.
         """
-        dir_path = self.getPath(oid)
-        contents = self.afs.computeContents(dir_path)
+        dir_path = self.get_path(oid)
+        contents = self.afs.compute_contents(dir_path)
         fn_to_name, name_to_fn = contents
-        existing = self.table.getChildren(oid) or {}
+        existing = self.table.get_children(oid) or {}
         for name, child_oid in children:
             assert child_oid
             if existing.has_key(name) and existing[name] != child_oid:
-                raise FSReadError("assignExisting() doesn't override")
+                raise FSReadError("assign_existing() doesn't override")
             filename = name_to_fn[name]
             self.table.add(oid, filename, child_oid)
 
-    def getModTime(self, oid, default=0):
+    def read_mod_time(self, oid, default=0):
         """Returns the time an object was last modified.
 
         Since objects are split into up to three files, this
         implementation returns the modification time of the most
         recently modified of the three.
         """
-        path = self.getPath(oid)
-        extra = self.afs.getAnnotationPaths(path)
+        path = self.get_path(oid)
+        extra = self.afs.get_annotation_paths(path)
         maxtime = -1
         for p in (path,) + tuple(extra):
             try:
@@ -199,9 +199,9 @@
                 t.append(None)
         return t
 
-    def getPollSources(self, oid):
-        path = self.getPath(oid)
-        extra = self.afs.getAnnotationPaths(path)
+    def get_sources(self, oid):
+        path = self.get_path(oid)
+        extra = self.afs.get_annotation_paths(path)
         paths = (path,) + tuple(extra)
         t = self._get_paths_mtime(paths)
         return {(self, paths): t}
@@ -245,39 +245,39 @@
         else:
             anns[name] = data
 
-    def writeNodeType(self, oid, data):
+    def write_node_type(self, oid, data):
         if data not in ('d', 'f'):
             raise FSWriteError(
                 'Node type must be "d" or "f" at %s' % oid)
         self._queue(oid, node_type_ann, data)
 
-    def writeData(self, oid, data, as_text=0):
+    def write_data(self, oid, data, as_text=0):
         if not isinstance(data, type('')):
             raise FSWriteError(
                 'Data for a file must be a string at %s' % oid)
         self._queue(oid, data_ann, (data, as_text))
 
-    def writeDirectory(self, oid, data):
+    def write_directory(self, oid, data):
         if isinstance(data, type('')):  # XXX Need a better check
             raise FSWriteError(
                 'Data for a directory must be a list or tuple at %s' % oid)
-        isLegalFilename = self.afs.isLegalFilename
+        is_legal_filename = self.afs.is_legal_filename
         for objname, child_oid in data:
             assert child_oid, "%s lacks a child_oid" % repr(objname)
-            if not isLegalFilename(objname):
+            if not is_legal_filename(objname):
                 raise FSWriteError(
                     'Not a legal object name: %s' % repr(objname))
         self._queue(oid, file_list_ann, data)
 
-    def writeAnnotation(self, oid, name, data):
-        self.afs.checkAnnotationName(name)
+    def write_annotation(self, oid, name, data):
+        self.afs.check_annotation_name(name)
         self._queue(oid, name, data)
 
-    def suggestExtension(self, oid, ext):
+    def suggest_extension(self, oid, ext):
         self._queue(oid, suggested_extension_ann, ext)
 
 
-    def _prepareContainerChanges(self, path, data):
+    def _prepare_container_changes(self, path, data):
         """Prepares the new dictionary of children for a directory.
 
         Chooses filenames for all of the directory's children.
@@ -289,7 +289,7 @@
         (objname, child_oid).  Returns {filename: child_oid}.
         """
         if path:
-            existing = self.afs.computeContents(path)[1]
+            existing = self.afs.compute_contents(path)[1]
             # existing contains {objname: filename}
         else:
             existing = {}
@@ -333,9 +333,9 @@
         """
         container_changes = {}  # {oid: {filename: child_oid}}
         for oid, anns in self._pending.items():
-            if self.table.getParents(oid) or oid == self.root_oid:
+            if self.table.get_parents(oid) or oid == self.root_oid:
                 # This is an existing object.  It has a path.
-                p = self.getSubpath(oid)
+                p = self.get_subpath(oid)
                 if p is None:
                     raise FSWriteError(
                         "No path known for OID %s" % repr(oid))
@@ -383,15 +383,15 @@
                     raise FSWriteError(
                         "A file exists where a directory is to be written. %s"
                         % info)
-                fn_oid = self._prepareContainerChanges(path, data)
+                fn_oid = self._prepare_container_changes(path, data)
                 container_changes[oid] = fn_oid
 
             else:
                 raise FSWriteError('Node type must be "d" or "f". %s' % info)
-        self._script = self._generateScript(container_changes)
+        self._script = self._generate_script(container_changes)
 
 
-    def _generateScript(self, container_changes):
+    def _generate_script(self, container_changes):
         """Generates the script for committing the transaction.
 
         Returns [(instruction, *args)].
@@ -399,7 +399,7 @@
         # container_changes is {oid: {filename: child_oid}}
         # script is [(instruction, *args)]
         script = []
-        script.append(("clearTemp",))
+        script.append(("clear_temp",))
 
         # Compute the number of times each relevant child_oid is to
         # be linked or unlinked.
@@ -412,7 +412,7 @@
             c[index] += 1
 
         for oid, new_children in container_changes.items():
-            old_children = self.table.getChildren(oid)
+            old_children = self.table.get_children(oid)
             if old_children is None:
                 old_children = {}
             for filename, child_oid in new_children.items():
@@ -436,7 +436,7 @@
         # then delete objects.
         to_delete = []  # [oid]
         for child_oid, (links, unlinks) in counts.items():
-            if not self.table.getParents(child_oid):
+            if not self.table.get_parents(child_oid):
                 # A new object should be added once or not at all.
                 if links > 1:
                     raise FSWriteError(
@@ -448,19 +448,19 @@
                         "Multiple links to %s" % repr(child_oid))
                 if links > 0:
                     # Moving.
-                    script.append(("moveToTemp", child_oid))
+                    script.append(("move_to_temp", child_oid))
                 elif unlinks > 0:
                     # Deleting.
                     to_delete.append(child_oid)
 
         for child_oid in to_delete:
             script.append(("delete", child_oid))
-        script.append(("writeAll", container_changes))
+        script.append(("write_all", container_changes))
         if self.app_filename and container_changes.has_key(self.root_oid):
             # Link or unlink the application object.
             root_changes = container_changes[self.root_oid]
-            script.append(("linkApp", root_changes.has_key(self.app_filename)))
-        script.append(("clearTemp",))
+            script.append(("link_app", root_changes.has_key(self.app_filename)))
+        script.append(("clear_temp",))
         return script
 
     def _rmrf(self, path):
@@ -476,7 +476,7 @@
             else:
                 ops.remove(path)
 
-    def _do_clearTemp(self):
+    def _do_clear_temp(self):
         """Script command: zap the temporary directory.
         """
         ops = self.ops
@@ -484,7 +484,7 @@
         self._rmrf(path)
         self._tmp_subpaths.clear()
 
-    def _moveBaseContents(self, src, dest):
+    def _move_base_contents(self, src, dest):
         """Move the base directory's contents, but not the directory.
 
         Also leaves behind the _root and _tmp subdirectories.
@@ -496,7 +496,7 @@
             if fn not in ('_root', '_tmp'):
                 ops.rename(ops.join(src, fn), ops.join(dest, fn))
 
-    def _moveItem(self, src, dest):
+    def _move_item(self, src, dest):
         """Moves a file or directory.
 
         For files, also moves annotations next to the file.
@@ -507,31 +507,31 @@
             ops.makedirs(parent)
         if not ops.isdir(src):
             # Move the annotation files also.
-            extra_src = self.afs.getAnnotationPaths(src)
-            extra_dest = self.afs.getAnnotationPaths(dest)
+            extra_src = self.afs.get_annotation_paths(src)
+            extra_dest = self.afs.get_annotation_paths(dest)
             for s, d in zip(extra_src, extra_dest):
                 if ops.exists(s):
                     ops.rename(s, d)
         ops.rename(src, dest)
 
-    def _do_moveToTemp(self, oid):
+    def _do_move_to_temp(self, oid):
         """Script command: move an object to the temporary directory.
         """
         ops = self.ops
-        src = self.getPath(oid)
+        src = self.get_path(oid)
         if src == self.basepath:
             # Move the base by moving most of the contents
             # instead of the actual directory.
             dest_sub = ('_tmp', 'base', 'data')
             dest = ops.join(self.basepath, *dest_sub)
-            self._moveBaseContents(src, dest)
+            self._move_base_contents(src, dest)
         else:
             # Move an object.
             dest_sub = ('_tmp', 'oid.%s' % oid, 'data')
             dest = ops.join(self.basepath, *dest_sub)
-            self._moveItem(src, dest)
+            self._move_item(src, dest)
         self._tmp_subpaths[oid] = dest_sub
-        parents = self.table.getParents(oid)
+        parents = self.table.get_parents(oid)
         for parent_oid, filename in parents:
             self.table.remove(parent_oid, filename)
 
@@ -539,20 +539,20 @@
         """Moves an object in the temp directory into the object system.
         """
         ops = self.ops
-        dest = self.getPath(oid)
+        dest = self.get_path(oid)
         src_sub = self._tmp_subpaths[oid]
         src = ops.join(self.basepath, *src_sub)
         if dest == self.basepath:
-            self._moveBaseContents(src, dest)
+            self._move_base_contents(src, dest)
         else:
-            self._moveItem(src, dest)
+            self._move_item(src, dest)
         del self._tmp_subpaths[oid]
 
     def _do_delete(self, oid):
         """Script command: delete an object.
         """
         ops = self.ops
-        path = self.getPath(oid)
+        path = self.get_path(oid)
         if path == self.basepath:
             # Delete the contents of the base directory.
             for fn in ops.listdir(path):
@@ -562,20 +562,20 @@
             # Delete an object.
             if not ops.isdir(path):
                 # Delete the annotation files also.
-                extra = self.afs.getAnnotationPaths(path)
+                extra = self.afs.get_annotation_paths(path)
                 for s in extra:
                     if ops.exists(s):
                         ops.remove(s)
             self._rmrf(path)
         if self._tmp_subpaths.has_key(oid):
             del self._tmp_subpaths[oid]
-        parents = self.table.getParents(oid)
+        parents = self.table.get_parents(oid)
         for parent_oid, filename in parents:
             self.table.remove(parent_oid, filename)
             # XXX Need to garbage collect descendants in the OID table.
 
 
-    def _do_writeAll(self, container_changes):
+    def _do_write_all(self, container_changes):
         """Script command: write all objects.
 
         Uses multiple passes.
@@ -586,7 +586,7 @@
         while self._pending:
             written = 0
             for oid, anns in self._pending.items():
-                p = self.getSubpath(oid)
+                p = self.get_subpath(oid)
                 if p is None:
                     # Not linked into the object system yet.
                     # Try again on the next pass.
@@ -621,7 +621,7 @@
                         self.afs.invalidate(path)
                     else:
                         to_write[name] = value
-                self.afs.writeAnnotations(path, to_write)
+                self.afs.write_annotations(path, to_write)
                 self.afs.invalidate(self.ops.dirname(path))
                 # This object has been written.
                 written += 1
@@ -638,7 +638,7 @@
                 break
 
 
-    def _do_linkApp(self, app_exists):
+    def _do_link_app(self, app_exists):
         """Script command: link or unlink the application object at the root.
         """
         path = self.ops.join(self.basepath, '_root', self.app_filename)
@@ -668,13 +668,13 @@
         if self.app_filename:
             # If there are objects at basepath, create a _root
             # containing an application also.
-            contents = self.afs.computeContents(self.basepath)
+            contents = self.afs.compute_contents(self.basepath)
             fn_to_name, name_to_fn = contents
             if fn_to_name:
-                self._do_linkApp(1)
+                self._do_link_app(1)
 
     def begin(self):
-        self.afs.clearCache()
+        self.afs.clear_cache()
 
     def vote(self):
         """Do some early verification


=== Products/Ape/lib/apelib/fs/interfaces.py 1.5 => 1.6 ===
--- Products/Ape/lib/apelib/fs/interfaces.py:1.5	Sat Feb 28 15:06:27 2004
+++ Products/Ape/lib/apelib/fs/interfaces.py	Sat Mar 20 01:34:23 2004
@@ -30,19 +30,19 @@
     """Filesystem reader that supports annotations.
     """
 
-    def getSubpath(oid):
+    def get_subpath(oid):
         """Returns the tuple path for an oid, relative to the base.
         """
 
-    def getPath(oid):
+    def get_path(oid):
         """Returns the filesystem path for an oid.
         """
 
-    def readNodeType(oid):
+    def read_node_type(oid):
         """Reads the node type of a filesystem node.
         """
 
-    def readData(oid, allow_missing=0, as_text=0):
+    def read_data(oid, allow_missing=0, as_text=0):
         """Reads the main data stream from a file.
 
         If the allow_missing flag is specified, this method returns
@@ -50,7 +50,7 @@
         is read in text mode.
         """
 
-    def readDirectory(oid, allow_missing=0):
+    def read_directory(oid, allow_missing=0):
         """Reads the contents of a directory.
 
         Returns a list of (object_name, child_oid).  The child_oid is
@@ -62,32 +62,32 @@
         None if no such directory is found.
         """
 
-    def readAnnotation(oid, name, default=None):
+    def read_annotation(oid, name, default=None):
         """Reads a text-based annotation for a file.
         """
 
-    def readObjectName(oid):
+    def read_object_name(oid):
         """Gets the canonical name for an object.
 
         Note that this only makes sense when objects can have only one
         parent.
         """
 
-    def assignExisting(oid, children):
+    def assign_existing(oid, children):
         """Assigns OIDs to previously existing objects on the filesystem.
 
-        See readDirectory().  children is a list of (object_name, child_oid).
+        See read_directory().  children is a list of (object_name, child_oid).
         """
 
-    def getExtension(oid):
+    def read_extension(oid):
         """Returns the filename extension for a file.
         """
 
-    def getModTime(oid, default=0):
+    def read_mod_time(oid, default=0):
         """Returns the last-modified time of a file.
         """
 
-    def getPollSources(oid):
+    def get_sources(oid):
         """Returns source information for an oid.
 
         The source information is a mapping that maps
@@ -102,29 +102,29 @@
     """Filesystem writer that supports annotations.
     """
 
-    def writeNodeType(oid, data):
+    def write_node_type(oid, data):
         """Writes the node type for a filesystem node.
 
         'd' (directory) and 'f' (file) are supported.
         """
 
-    def writeData(oid, data, as_text=0):
+    def write_data(oid, data, as_text=0):
         """Writes string data to a filesystem node.
 
         If 'as_text' is true, the file is written in text mode.
         """
 
-    def writeDirectory(oid, data):
+    def write_directory(oid, data):
         """Writes data to a directory.
 
         'data' is a sequence of (object_name, child_oid).
         """
 
-    def writeAnnotation(oid, name, data):
+    def write_annotation(oid, name, data):
         """Writes a text-based annotation for a filesystem node.
         """
 
-    def suggestExtension(oid, ext):
+    def suggest_extension(oid, ext):
         """Suggests a filename extension for a filesystem node.
 
         The IFSConnection may use this information to store the file


=== Products/Ape/lib/apelib/fs/oidtable.py 1.2 => 1.3 ===
--- Products/Ape/lib/apelib/fs/oidtable.py:1.2	Sat Feb 28 15:06:27 2004
+++ Products/Ape/lib/apelib/fs/oidtable.py	Sat Mar 20 01:34:23 2004
@@ -68,7 +68,7 @@
         if not p:
             del self.back[child_oid]
 
-    def setChildren(self, parent_oid, new_children):
+    def set_children(self, parent_oid, new_children):
         """Updates all children for a parent.
 
         new_children is {filename: child_oid}.  Calls self.add() and
@@ -95,7 +95,7 @@
         for filename, child_oid in old_children.items():
             self.remove(parent_oid, filename)
 
-    def getPath(self, ancestor_oid, descendant_oid):
+    def get_path(self, ancestor_oid, descendant_oid):
         """Returns the primary path that connects two OIDs.
 
         The primary path follows the first parent of each OID.
@@ -118,14 +118,14 @@
         parts.reverse()
         return parts
 
-    def getChildren(self, parent_oid):
+    def get_children(self, parent_oid):
         """Returns the children of an OID as a mapping of {filename: oid}.
 
         Do not modify the return value.
         """
         return self.fwd.get(parent_oid)
 
-    def getParents(self, child_oid):
+    def get_parents(self, child_oid):
         """Returns the parents of an OID as a list of (oid, filename).
 
         Do not modify the return value.


=== Products/Ape/lib/apelib/fs/params.py 1.2 => 1.3 ===
--- Products/Ape/lib/apelib/fs/params.py:1.2	Sat Feb 28 15:06:27 2004
+++ Products/Ape/lib/apelib/fs/params.py	Sat Mar 20 01:34:23 2004
@@ -30,7 +30,7 @@
 key_re = re.compile(r'[A-Za-z_-][A-Za-z0-9_-]*$')
 
 
-def splitParams(s):
+def split_params(s):
     tokens = re.split(token_re, s)
     params = []
     param = []
@@ -58,17 +58,17 @@
     return params
 
 
-def escapeParam(s):
+def escape_param(s):
     return s.replace('\\', '\\\\').replace('"', '\\"').replace(
         '\r', '\\r').replace('\n', '\\n').replace('\t', '\\t')
 
 
-def stringToParams(s):
+def string_to_params(s):
     """Decodes a string of the format 'a="..." b="..."'.
 
     Returns a list of (key, value) pairs.
     """
-    params = splitParams(s)
+    params = split_params(s)
     res = []
     for param in params:
         p = param.split('=', 1)
@@ -81,14 +81,14 @@
     return res
 
 
-def paramsToString(params):
+def params_to_string(params):
     """Encodes a list of (key, value) pairs as a string."""
     parts = []
     for k, v in params:
         if not key_re.match(k):
             raise ValueError, 'Bad parameter name: %s' % repr(k)
         if v:
-            parts.append('%s="%s"' % (k, escapeParam(v)))
+            parts.append('%s="%s"' % (k, escape_param(v)))
         else:
             parts.append(k)
     return ' '.join(parts)


=== Products/Ape/lib/apelib/fs/properties.py 1.5 => 1.6 ===
--- Products/Ape/lib/apelib/fs/properties.py:1.5	Sat Feb 28 15:06:27 2004
+++ Products/Ape/lib/apelib/fs/properties.py	Sat Mar 20 01:34:23 2004
@@ -64,17 +64,17 @@
     __implements__ = IGateway
 
     schema = RowSequenceSchema()
-    schema.addField('id', 'string', 1)
-    schema.addField('type', 'string')
-    schema.addField('data', 'string')
+    schema.add('id', 'string', 1)
+    schema.add('type', 'string')
+    schema.add('data', 'string')
 
     def __init__(self, annotation='properties', conn_name='fs'):
         self.annotation = str(annotation)
         FSGatewayBase.__init__(self, conn_name)
 
     def load(self, event):
-        fs_conn = self.getConnection(event)
-        text = fs_conn.readAnnotation(event.oid, self.annotation, '')
+        fs_conn = self.get_connection(event)
+        text = fs_conn.read_annotation(event.oid, self.annotation, '')
         res = []
         if text:
             lines = text.split('\n')
@@ -95,8 +95,8 @@
             lines.append('%s:%s=%s' % (k, t, escape_string(v)))
         lines.sort()
         text = '\n'.join(lines)
-        fs_conn = self.getConnection(event)
-        fs_conn.writeAnnotation(event.oid, self.annotation, text)
+        fs_conn = self.get_connection(event)
+        fs_conn.write_annotation(event.oid, self.annotation, text)
         state = list(state)
         state.sort()
         return tuple(state)
@@ -114,8 +114,8 @@
         FSGatewayBase.__init__(self, conn_name)
 
     def load(self, event):
-        fs_conn = self.getConnection(event)
-        state = fs_conn.readAnnotation(event.oid, self.annotation, '').strip()
+        fs_conn = self.get_connection(event)
+        state = fs_conn.read_annotation(event.oid, self.annotation, '').strip()
         return state, state
 
     def store(self, event, state):
@@ -123,6 +123,6 @@
             raise ValueError('Not a string: %s' % repr(state))
         state = state.strip()
         if state:
-            fs_conn = self.getConnection(event)
-            fs_conn.writeAnnotation(event.oid, self.annotation, state)
+            fs_conn = self.get_connection(event)
+            fs_conn.write_annotation(event.oid, self.annotation, state)
         return state


=== Products/Ape/lib/apelib/fs/security.py 1.4 => 1.5 ===
--- Products/Ape/lib/apelib/fs/security.py:1.4	Sat Feb 28 15:06:27 2004
+++ Products/Ape/lib/apelib/fs/security.py	Sat Mar 20 01:34:23 2004
@@ -18,7 +18,7 @@
 
 from apelib.core.interfaces import IGateway, MappingError
 from apelib.core.schemas import RowSequenceSchema
-from params import stringToParams, paramsToString
+from params import string_to_params, params_to_string
 
 from base import FSGatewayBase
 
@@ -29,18 +29,18 @@
     __implements__ = IGateway
 
     schema = RowSequenceSchema()
-    schema.addField('declaration_type', 'string')
-    schema.addField('role', 'string')
-    schema.addField('permission', 'string')
-    schema.addField('username', 'string')
+    schema.add('declaration_type', 'string')
+    schema.add('role', 'string')
+    schema.add('permission', 'string')
+    schema.add('username', 'string')
 
     def __init__(self, annotation='security', conn_name='fs'):
         self.annotation = annotation
         FSGatewayBase.__init__(self, conn_name)
 
     def load(self, event):
-        fs_conn = self.getConnection(event)
-        text = fs_conn.readAnnotation(event.oid, self.annotation, '')
+        fs_conn = self.get_connection(event)
+        text = fs_conn.read_annotation(event.oid, self.annotation, '')
         res = []
         if text:
             lines = text.split('\n')
@@ -48,7 +48,7 @@
                 line = line.strip()
                 if not line or line.startswith('#'):
                     continue
-                params = stringToParams(line)
+                params = string_to_params(line)
                 if params:
                     decl_type = params[0][0]
                     row = [decl_type, '', '', '']
@@ -82,13 +82,13 @@
                 params.append(('permission', p))
             if u:
                 params.append(('username', u))
-            s = paramsToString(params)
+            s = params_to_string(params)
             lines.append(s)
         if lines:
             lines.sort()
             text = '\n'.join(lines)
-            fs_conn = self.getConnection(event)
-            fs_conn.writeAnnotation(event.oid, self.annotation, text)
+            fs_conn = self.get_connection(event)
+            fs_conn.write_annotation(event.oid, self.annotation, text)
         state = list(state)
         state.sort()
         return tuple(state)
@@ -101,32 +101,32 @@
     __implements__ = IGateway
 
     schema = RowSequenceSchema()
-    schema.addField('id', 'string', 1)
-    schema.addField('password', 'string')
-    schema.addField('roles', 'string:list')
-    schema.addField('domains', 'string:list')
+    schema.add('id', 'string', 1)
+    schema.add('password', 'string')
+    schema.add('roles', 'string:list')
+    schema.add('domains', 'string:list')
 
     def load(self, event):
-        c = self.getConnection(event)
-        assert c.readNodeType(event.oid) == 'f'
-        text = c.readData(event.oid)
+        c = self.get_connection(event)
+        assert c.read_node_type(event.oid) == 'f'
+        text = c.read_data(event.oid)
         res = []
         for line in text.split('\n'):
             L = line.strip()
             if not L.startswith('#') and ':' in L:
                 id, password, rolelist, domainlist = L.split(':', 3)
-                roles = self._splitList(rolelist)
-                domains = self._splitList(domainlist)
+                roles = self._split_list(rolelist)
+                domains = self._split_list(domainlist)
                 res.append((id, password, roles, domains))
         res.sort()
         return res, text
 
 
-    def _splitList(self, s):
+    def _split_list(self, s):
         return tuple([item.strip() for item in s.split(',') if item])
 
 
-    def _joinList(self, items):
+    def _join_list(self, items):
         for item in items:
             if item.strip() != item:
                 raise MappingError(
@@ -151,15 +151,15 @@
                 raise MappingError('User IDs cannot start with #')
             if ':' in password or '\n' in password:
                 raise MappingError('Passwords cannot have colons or newlines')
-            rolelist = self._joinList(roles)
-            domainlist = self._joinList(domains)
+            rolelist = self._join_list(roles)
+            domainlist = self._join_list(domains)
             to_write = '%s:%s:%s:%s' % (id, password, rolelist, domainlist)
             replace_lines[id] = to_write
         oid = event.oid
-        fs_conn = self.getConnection(event)
-        fs_conn.writeNodeType(oid, 'f')
+        fs_conn = self.get_connection(event)
+        fs_conn.write_node_type(oid, 'f')
         # Read the existing text only to maintain the current order.
-        text = fs_conn.readData(oid, allow_missing=1)
+        text = fs_conn.read_data(oid, allow_missing=1)
         if text is None:
             text = ''
         new_lines = []
@@ -181,7 +181,7 @@
             new_lines.append(line)
         # Write it
         text = '\n'.join(new_lines)
-        fs_conn.writeData(oid, text)
+        fs_conn.write_data(oid, text)
         serial = list(state)
         serial.sort()
         return text


=== Products/Ape/lib/apelib/fs/structure.py 1.9 => 1.10 ===
--- Products/Ape/lib/apelib/fs/structure.py:1.9	Tue Mar 16 23:00:48 2004
+++ Products/Ape/lib/apelib/fs/structure.py	Sat Mar 20 01:34:23 2004
@@ -41,17 +41,17 @@
         FSGatewayBase.__init__(self, conn_name)
 
     def load(self, event):
-        c = self.getConnection(event)
-        assert c.readNodeType(event.oid) == 'f'
-        state = c.readData(event.oid, as_text=self.text)
+        c = self.get_connection(event)
+        assert c.read_node_type(event.oid) == 'f'
+        state = c.read_data(event.oid, as_text=self.text)
         return state, state
 
     def store(self, event, state):
         if not isinstance(state, StringType):
             raise ValueError('Not a string: %s' % repr(state))
-        c = self.getConnection(event)
-        c.writeNodeType(event.oid, 'f')
-        c.writeData(event.oid, state, as_text=self.text)
+        c = self.get_connection(event)
+        c.write_node_type(event.oid, 'f')
+        c.write_data(event.oid, state, as_text=self.text)
         return state
 
 
@@ -64,7 +64,7 @@
     schema = FieldSchema('id', 'string')
 
     def load(self, event):
-        id = self.getConnection(event).readObjectName(event.oid)
+        id = self.get_connection(event).read_object_name(event.oid)
         # Disable conflict checking by returning None as the hash value.
         return id, None
 
@@ -72,9 +72,9 @@
         # Ignore.
         return None
 
-    def getPollSources(self, event):
-        fs_conn = self.getConnection(event)
-        return fs_conn.getPollSources(event.oid)
+    def get_sources(self, event):
+        fs_conn = self.get_connection(event)
+        return fs_conn.get_sources(event.oid)
 
 
 class FSDirectoryItems (FSGatewayBase):
@@ -83,15 +83,15 @@
     __implements__ = IGateway
 
     schema = RowSequenceSchema()
-    schema.addField('key', 'string', 1)
-    schema.addField('oid', 'string')
-    schema.addField('classification', 'classification')
+    schema.add('key', 'string', 1)
+    schema.add('oid', 'string')
+    schema.add('classification', 'classification')
 
     def load(self, event):
-        c = self.getConnection(event)
-        if c.readNodeType(event.oid) != 'd':
+        c = self.get_connection(event)
+        if c.read_node_type(event.oid) != 'd':
             raise LoadError("Not a directory")
-        data = list(c.readDirectory(event.oid))
+        data = list(c.read_directory(event.oid))
         data.sort()
         # Assign OIDs to previously existing subobjects.
         assigned = {}
@@ -101,7 +101,7 @@
                 assigned[objname] = child_oid
         if assigned:
             # Saw existing objects.  Tell the connection what their OIDs are.
-            c.assignExisting(event.oid, assigned.items())
+            c.assign_existing(event.oid, assigned.items())
         # Return the results.
         res = []
         hash_value = []
@@ -115,13 +115,13 @@
         return res, tuple(hash_value)
 
     def store(self, event, state):
-        c = self.getConnection(event)
-        c.writeNodeType(event.oid, 'd')
+        c = self.get_connection(event)
+        c.write_node_type(event.oid, 'd')
         data = []
         for objname, child_oid, classification in state:
             data.append((objname, child_oid))
         data.sort()
-        c.writeDirectory(event.oid, data)
+        c.write_directory(event.oid, data)
         return tuple(data)
 
 
@@ -133,8 +133,8 @@
     schema = FieldSchema('mtime', 'int')
 
     def load(self, event):
-        fs_conn = self.getConnection(event)
-        state = long(fs_conn.getModTime(event.oid))
+        fs_conn = self.get_connection(event)
+        state = long(fs_conn.read_mod_time(event.oid))
         return state, None  # Use None as the hash (see store())
 
     def store(self, event, state):




More information about the Zope-CVS mailing list