From 58c5a246e72fd86f7af713d621498df68a1b1aa0 Mon Sep 17 00:00:00 2001
From: Nicolas Dandrimont <nicolas@dandrimont.eu>
Date: Tue, 14 Feb 2017 18:34:48 +0100
Subject: [PATCH] git: don't use double underscores for function names

---
 swh/model/git.py            | 26 +++++++++++++-------------
 swh/model/tests/test_git.py | 16 ++++++++--------
 2 files changed, 21 insertions(+), 21 deletions(-)

diff --git a/swh/model/git.py b/swh/model/git.py
index 6cc7019a..a3503cbb 100644
--- a/swh/model/git.py
+++ b/swh/model/git.py
@@ -241,9 +241,9 @@ def default_validation_dir(dirpath):
     return True
 
 
-def __walk(rootdir,
-           dir_ok_fn=default_validation_dir,
-           remove_empty_folder=False):
+def _walk(rootdir,
+          dir_ok_fn=default_validation_dir,
+          remove_empty_folder=False):
     """Walk the filesystem and yields a 3 tuples (dirpath, dirnames as set
     of absolute paths, filenames as set of abslute paths)
 
@@ -379,7 +379,7 @@ def walk_and_compute_sha1_from_directory(rootdir,
     if rootdir.endswith(b'/'):
         rootdir = rootdir.rstrip(b'/')
 
-    for dirpath, dirnames, filenames in __walk(
+    for dirpath, dirnames, filenames in _walk(
             rootdir, dir_ok_fn, remove_empty_folder):
         hashes = []
 
@@ -456,13 +456,13 @@ def compute_hashes_from_directory(rootdir,
         If something is raised, this is a programmatic error.
 
     """
-    def __get_dict_from_dirpath(_dict, path):
+    def _get_dict_from_dirpath(_dict, path):
         """Retrieve the default associated value for key path.
 
         """
         return _dict.get(path, dict(children=set(), checksums=None))
 
-    def __get_dict_from_filepath(_dict, path):
+    def _get_dict_from_filepath(_dict, path):
         """Retrieve the default associated value for key path.
 
         """
@@ -474,10 +474,10 @@ def compute_hashes_from_directory(rootdir,
     if rootdir.endswith(b'/'):
         rootdir = rootdir.rstrip(b'/')
 
-    for dirpath, dirnames, filenames in __walk(
+    for dirpath, dirnames, filenames in _walk(
             rootdir, dir_ok_fn, remove_empty_folder):
 
-        dir_entry = __get_dict_from_dirpath(ls_hashes, dirpath)
+        dir_entry = _get_dict_from_dirpath(ls_hashes, dirpath)
         children = dir_entry['children']
 
         links = (file
@@ -487,25 +487,25 @@ def compute_hashes_from_directory(rootdir,
         for linkpath in links:
             all_links.add(linkpath)
             m_hashes = compute_link_metadata(linkpath)
-            d = __get_dict_from_filepath(ls_hashes, linkpath)
+            d = _get_dict_from_filepath(ls_hashes, linkpath)
             d['checksums'] = m_hashes
             ls_hashes[linkpath] = d
             children.add(linkpath)
 
         for filepath in (file for file in filenames if file not in all_links):
             m_hashes = compute_blob_metadata(filepath)
-            d = __get_dict_from_filepath(ls_hashes, filepath)
+            d = _get_dict_from_filepath(ls_hashes, filepath)
             d['checksums'] = m_hashes
             ls_hashes[filepath] = d
             children.add(filepath)
 
         for fulldirname in (dir for dir in dirnames if dir not in all_links):
-            d_hashes = __get_dict_from_dirpath(ls_hashes, fulldirname)
+            d_hashes = _get_dict_from_dirpath(ls_hashes, fulldirname)
             tree_hash = _compute_tree_metadata(
                 fulldirname,
                 (ls_hashes[p]['checksums'] for p in d_hashes['children'])
             )
-            d = __get_dict_from_dirpath(ls_hashes, fulldirname)
+            d = _get_dict_from_dirpath(ls_hashes, fulldirname)
             d['checksums'] = tree_hash
             ls_hashes[fulldirname] = d
             children.add(fulldirname)
@@ -514,7 +514,7 @@ def compute_hashes_from_directory(rootdir,
         ls_hashes[dirpath] = dir_entry
 
     # compute the current directory hashes
-    d_hashes = __get_dict_from_dirpath(ls_hashes, rootdir)
+    d_hashes = _get_dict_from_dirpath(ls_hashes, rootdir)
     root_hash = {
         'sha1_git': _compute_directory_git_sha1(
             (ls_hashes[p]['checksums'] for p in d_hashes['children'])
diff --git a/swh/model/tests/test_git.py b/swh/model/tests/test_git.py
index f58057a5..b1eac8cb 100644
--- a/swh/model/tests/test_git.py
+++ b/swh/model/tests/test_git.py
@@ -517,7 +517,7 @@ class TestObjectsPerType(WithSampleFolderChecksums, unittest.TestCase):
 
     @istest
     def objects_per_type_tree(self):
-        def __children_hashes(path, objects=self.objects):
+        def _children_hashes(path, objects=self.objects):
             return set((c['sha1_git']
                        for c in git.children_hashes(
                            objects[path]['children'], objects)))
@@ -531,7 +531,7 @@ class TestObjectsPerType(WithSampleFolderChecksums, unittest.TestCase):
                 'perms': git.GitPerm.TREE,
                 # we only add children's sha1_git here, in reality,
                 # it's a full dict of hashes.
-                'children': __children_hashes(b'/tmp/tmp7w3oi_j8')
+                'children': _children_hashes(b'/tmp/tmp7w3oi_j8')
             },
             {
                 'type': git.GitType.TREE,
@@ -539,7 +539,7 @@ class TestObjectsPerType(WithSampleFolderChecksums, unittest.TestCase):
                 'sha1_git': b'\xe8\xb0\xf1Fj\xf8`\x8c\x8a?\xb9\x87\x9d\xb1r\xb8\x87\xe8\x07Y',  # noqa
                 'path': b'/tmp/tmp7w3oi_j8/sample-folder',
                 'perms': git.GitPerm.TREE,
-                'children': __children_hashes(
+                'children': _children_hashes(
                     b'/tmp/tmp7w3oi_j8/sample-folder')
             },
             {
@@ -548,7 +548,7 @@ class TestObjectsPerType(WithSampleFolderChecksums, unittest.TestCase):
                 'sha1_git': b'K\x82]\xc6B\xcbn\xb9\xa0`\xe5K\xf8\xd6\x92\x88\xfb\xeeI\x04',  # noqa
                 'path': b'/tmp/tmp7w3oi_j8/sample-folder/empty-folder',
                 'perms': git.GitPerm.TREE,
-                'children': __children_hashes(
+                'children': _children_hashes(
                     b'/tmp/tmp7w3oi_j8/sample-folder/empty-folder')
             },
             {
@@ -557,7 +557,7 @@ class TestObjectsPerType(WithSampleFolderChecksums, unittest.TestCase):
                 'sha1_git': b'<\x1fW\x83\x94\xf4b?t\xa0\xba\x7f\xe7ar\x9fY\xfcn\xc4',  # noqa
                 'path': b'/tmp/tmp7w3oi_j8/sample-folder/bar',
                 'perms': git.GitPerm.TREE,
-                'children': __children_hashes(
+                'children': _children_hashes(
                     b'/tmp/tmp7w3oi_j8/sample-folder/bar')
             },
             {
@@ -566,7 +566,7 @@ class TestObjectsPerType(WithSampleFolderChecksums, unittest.TestCase):
                 'sha1_git': b'\xc3\x02\x0fk\xf15\xa3\x8cm\xf3\xaf\xeb_\xb3\x822\xc5\xe0p\x87',  # noqa
                 'path': b'/tmp/tmp7w3oi_j8/sample-folder/bar/barfoo',
                 'perms': git.GitPerm.TREE,
-                'children': __children_hashes(
+                'children': _children_hashes(
                     b'/tmp/tmp7w3oi_j8/sample-folder/bar/barfoo'),
             },
             {
@@ -575,7 +575,7 @@ class TestObjectsPerType(WithSampleFolderChecksums, unittest.TestCase):
                 'sha1_git': b'+A\xc4\x0f\r\x1f\xbf\xfc\xba\x12I}\xb7\x1f\xba\x83\xfc\xca\x96\xe5',  # noqa
                 'path': b'/tmp/tmp7w3oi_j8/sample-folder/foo',
                 'perms': git.GitPerm.TREE,
-                'children': __children_hashes(
+                'children': _children_hashes(
                     b'/tmp/tmp7w3oi_j8/sample-folder/foo')
             },
         ]
@@ -585,7 +585,7 @@ class TestObjectsPerType(WithSampleFolderChecksums, unittest.TestCase):
 
         # when
         actual_sha1_trees = list(
-            ((c['sha1_git'], c['type'], __children_hashes(c['path']))
+            ((c['sha1_git'], c['type'], _children_hashes(c['path']))
              for c in git.objects_per_type(git.GitType.TREE, self.objects)))
 
         self.assertEquals(len(actual_sha1_trees), len(expected_sha1_trees))
-- 
GitLab