From d58f6f2fe3b172573eac3aa2ca94221033659985 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Fri, 12 Oct 2012 10:35:30 -0400 Subject: [PATCH] git-publish.py: bump to Python 3. --- posts/Git/git-publish.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/posts/Git/git-publish.py b/posts/Git/git-publish.py index 278c8f6..35d22ea 100755 --- a/posts/Git/git-publish.py +++ b/posts/Git/git-publish.py @@ -27,10 +27,13 @@ import os.path as _os_path import shutil as _shutil import subprocess as _subprocess import tempfile as _tempfile -import urlparse as _urlparse +try: # Python 3 + import urllib.parse as _urllib_parse +except ImportError: # Python 2 + import urlparse as _urllib_parse -__version__ = '0.2' +__version__ = '0.3' _LOG = _logging.getLogger('git-publish') _LOG.addHandler(_logging.StreamHandler()) @@ -48,7 +51,7 @@ def parse_remote(remote): ('jdoe', 'example.com', 2222, '/a/b/c') """ _LOG.debug("parse {} using Git's URL syntax".format(remote)) - p = _urlparse.urlparse(remote) + p = _urllib_parse.urlparse(remote) assert p.scheme == 'ssh', p.scheme assert p.params == '', p.params assert p.query == '', p.query @@ -118,7 +121,7 @@ def make_bare_local_checkout(repo): _shutil.move(_os_path.join(bare, 'hooks', 'post-update.sample'), _os_path.join(bare, 'hooks', 'post-update')) git(repo=bare, args=['--bare', 'update-server-info']) - _os.chmod(bare, 0755) + _os.chmod(bare, 0o0755) return bare def recursive_copy(source, user, host, port, path): -- 2.26.2