changeset 9488:33a6213a974e

zeroconf: code cleanup, fixing variable names to be meaningful
author Alexander Solovyov <piranha@piranha.org.ua>
date Sat, 26 Sep 2009 00:17:02 +0300
parents 90ae579924e4
children cec4b0d3fb02
files hgext/zeroconf/__init__.py
diffstat 1 files changed, 16 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/zeroconf/__init__.py	Mon Sep 28 13:21:41 2009 -0700
+++ b/hgext/zeroconf/__init__.py	Sat Sep 26 00:17:02 2009 +0300
@@ -109,12 +109,12 @@
     def __init__(self, conf, baseui=None):
         super(hgwebdirzc, self).__init__(conf, baseui)
         prefix = self.ui.config("web", "prefix", "").strip('/') + '/'
-        for r, p in self.repos:
+        for repo, path in self.repos:
             u = self.ui.copy()
-            u.readconfig(os.path.join(p, '.hg', 'hgrc'))
-            n = os.path.basename(r)
-            path = (prefix + r).strip('/')
-            publish(n, "hgweb", path, int(u.config("web", "port", 8000)))
+            u.readconfig(os.path.join(path, '.hg', 'hgrc'))
+            name = os.path.basename(repo)
+            path = (prefix + repo).strip('/')
+            publish(name, "hgweb", path, int(u.config("web", "port", 8000)))
 
 # listen
 
@@ -136,25 +136,24 @@
     Zeroconf.ServiceBrowser(server, "_hg._tcp.local.", l)
     time.sleep(1)
     server.close()
-    for v in l.found.values():
-        n = v.name[:v.name.index('.')]
-        n.replace(" ", "-")
-        u = "http://%s:%s%s" % (socket.inet_ntoa(v.address), v.port,
-                                 v.properties.get("path", "/"))
-        yield "zc-" + n, u
+    for value in l.found.values():
+        name = value.name[:value.name.index('.')]
+        url = "http://%s:%s%s" % (socket.inet_ntoa(value.address), value.port,
+                                  value.properties.get("path", "/"))
+        yield "zc-" + name, url
 
 def config(orig, self, section, key, default=None, untrusted=False):
     if section == "paths" and key.startswith("zc-"):
-        for n, p in getzcpaths():
-            if n == key:
-                return p
+        for name, path in getzcpaths():
+            if name == key:
+                return path
     return orig(self, section, key, default, untrusted)
 
 def configitems(orig, self, section, untrusted=False):
-    r = orig(self, section, untrusted)
+    repos = orig(self, section, untrusted)
     if section == "paths":
-        r += getzcpaths()
-    return r
+        repos += getzcpaths()
+    return repos
 
 extensions.wrapfunction(ui.ui, 'config', config)
 extensions.wrapfunction(ui.ui, 'configitems', configitems)