From 63b6aae46eded35ea027105045bfa2ffcbca3738 Mon Sep 17 00:00:00 2001 From: Daniel Harding Date: Tue, 5 Jun 2012 21:34:05 +0100 Subject: More Python 3 fixes cli.py was not Python 3-compatible. Added code to handle the ConfigParser -> configparser rename, as well as print becoming a function. --- dotfiles/cli.py | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/dotfiles/cli.py b/dotfiles/cli.py index c14c0e8..00baf99 100644 --- a/dotfiles/cli.py +++ b/dotfiles/cli.py @@ -10,7 +10,10 @@ from __future__ import absolute_import import os from . import core -import ConfigParser +try: + import ConfigParser as configparser +except ImportError: + import configparser from optparse import OptionParser, OptionGroup defaults = { @@ -31,7 +34,7 @@ settings = { def missing_default_repo(): """Print a helpful message when the default repository is missing.""" - print """ + print(""" If this is your first time running dotfiles, you must first create a repository. By default, dotfiles will look for '{0}'. Something like: @@ -49,7 +52,7 @@ would look like: repository = {0} Type 'dotfiles -h' to see detailed usage information.""".format( - defaults['repository']) + defaults['repository'])) def add_global_flags(parser): @@ -122,12 +125,12 @@ def parse_args(): (opts, args) = parser.parse_args() if opts.show_version: - print 'dotfiles v%s' % core.__version__ + print('dotfiles v%s' % core.__version__) exit(0) if not opts.action: - print "Error: An action is required. Type 'dotfiles -h' to see " \ - "detailed usage information." + print("Error: An action is required. Type 'dotfiles -h' to see " \ + "detailed usage information.") exit(-1) return (opts, args) @@ -135,7 +138,7 @@ def parse_args(): def parse_config(config_file): - parser = ConfigParser.SafeConfigParser() + parser = configparser.SafeConfigParser() parser.read(config_file) opts = {'repository': None, @@ -146,17 +149,17 @@ def parse_config(config_file): for entry in ('repository', 'prefix'): try: opts[entry] = parser.get('dotfiles', entry) - except ConfigParser.NoOptionError: + except configparser.NoOptionError: pass - except ConfigParser.NoSectionError: + except configparser.NoSectionError: break for entry in ('ignore', 'externals'): try: opts[entry] = eval(parser.get('dotfiles', entry)) - except ConfigParser.NoOptionError: + except configparser.NoOptionError: pass - except ConfigParser.NoSectionError: + except configparser.NoSectionError: break return opts @@ -171,11 +174,11 @@ def dispatch(dotfiles, action, force, args): dotfiles.sync(force) elif action == 'move': if len(args) > 1: - print "Error: Move cannot handle multiple targets." + print("Error: Move cannot handle multiple targets.") exit(-1) dotfiles.move(args[0]) else: - print "Error: Something truly terrible has happened." + print("Error: Something truly terrible has happened.") exit(-1) @@ -190,8 +193,8 @@ def realpath(path): def check_repository_exists(): if not os.path.exists(settings['repository']): - print 'Error: Could not find dotfiles repository \"%s\"' % ( - settings['repository']) + print('Error: Could not find dotfiles repository \"%s\"' % ( + settings['repository'])) if compare_path(settings['repository'], defaults['repository']): missing_default_repo() exit(-1) -- cgit v1.2.3 From b23ae5d8c74c956ea58949c594a252f8bb552854 Mon Sep 17 00:00:00 2001 From: Jon Bernard Date: Sun, 10 Jun 2012 21:52:13 -0400 Subject: Update history and bump version number --- HISTORY.rst | 5 +++++ dotfiles/core.py | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/HISTORY.rst b/HISTORY.rst index cf407a8..b17a94b 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -1,6 +1,11 @@ History ------- +0.5.4 ++++++ + +* More Python 3 fixes + 0.5.3 +++++ diff --git a/dotfiles/core.py b/dotfiles/core.py index 26ff48a..4e08073 100644 --- a/dotfiles/core.py +++ b/dotfiles/core.py @@ -12,7 +12,7 @@ import shutil import fnmatch -__version__ = '0.5.3' +__version__ = '0.5.4' __author__ = 'Jon Bernard' __license__ = 'ISC' -- cgit v1.2.3