Skip to content
Browse files

pep8 injection

  • Loading branch information...
1 parent 066c34d commit a0ac19bcfdde119297ea1d2b3a662966b01f5334 @dcolish dcolish committed Feb 13, 2012
Showing with 47 additions and 42 deletions.
  1. +3 −2 fabfile/__init__.py
  2. +1 −3 fabfile/docs.py
  3. +7 −3 fabfile/tag.py
  4. +0 −1 fabfile/utils.py
  5. +3 −1 fabric/exceptions.py
  6. +2 −1 fabric/io.py
  7. +6 −9 fabric/job_queue.py
  8. +10 −7 fabric/main.py
  9. +2 −3 fabric/network.py
  10. +8 −8 fabric/operations.py
  11. +1 −1 fabric/sftp.py
  12. +2 −2 fabric/state.py
  13. +2 −1 fabric/task_utils.py
View
5 fabfile/__init__.py
@@ -6,9 +6,10 @@
import nose
-from fabric.api import *
+from fabric.api import abort, local, task
-import docs, tag
+import docs
+import tag
from utils import msg
View
4 fabfile/docs.py
@@ -1,8 +1,6 @@
from __future__ import with_statement
-from fabric.api import *
-from fabric.contrib.project import rsync_project
-from fabric.version import get_version
+from fabric.api import lcd, local, task
@task(default=True)
View
10 fabfile/tag.py
@@ -2,7 +2,7 @@
from contextlib import nested
-from fabric.api import *
+from fabric.api import abort, hide, local, settings, task
# Need to import this as fabric.version for reload() purposes
import fabric.version
@@ -17,18 +17,21 @@ def _seek_version(cmd, txt):
cmd = cmd % _version('short')
return local(cmd, capture=True)
+
def current_version_is_tagged():
return _seek_version(
'git tag | egrep "^%s$"',
"Searching for existing tag"
)
+
def current_version_is_changelogged(filename):
return _seek_version(
'egrep "^\* :release:`%s " filename',
"Looking for changelog entry"
)
+
def update_code(filename, force):
"""
Update version data structure in-code and commit that change to git.
@@ -46,6 +49,7 @@ def update_code(filename, force):
abort("You seem to have aborted the file edit, so I'm aborting too.")
return filename
+
def commits_since_last_tag():
"""
Has any work been done since the last tag?
@@ -89,9 +93,9 @@ def tag(force='no', push='no'):
# Similar process but for the changelog.
changelog = "docs/changelog.rst"
if not current_version_is_changelogged(changelog):
- changed.append(update_code(changelog, force))
+ changed.append(update_code(changelog, force))
else:
- print("Changelog already updated, no need to edit...")
+ print("Changelog already updated, no need to edit...")
# Commit any changes
if changed:
with msg("Committing updated version and/or changelog"):
View
1 fabfile/utils.py
@@ -11,4 +11,3 @@ def msg(txt):
with hide('everything'):
yield
puts("done.", show_prefix=False, flush=True)
-
View
4 fabric/exceptions.py
@@ -1,9 +1,11 @@
"""
Custom Fabric exception classes.
-Most are simply distinct Exception subclasses for purposes of message-passing (though typically still in actual error situations.)
+Most are simply distinct Exception subclasses for purposes of message-passing
+(though typically still in actual error situations.)
"""
+
class NetworkError(Exception):
# Must allow for calling with zero args/kwargs, since pickle is apparently
# stupid with exceptions and tries to call it as such when passed around in
View
3 fabric/io.py
@@ -4,7 +4,6 @@
import time
from select import select
-from fabric.context_managers import settings, char_buffered
from fabric.state import env, output, win32
from fabric.auth import get_password, set_password
import fabric.network
@@ -24,9 +23,11 @@ def _endswith(char_list, substring):
substring = list(substring)
return tail == substring
+
def _is_newline(byte):
return byte in ('\n', '\r')
+
def _was_newline(capture, byte):
"""
Determine if we are 'past' a newline and need to print the line prefix.
View
15 fabric/job_queue.py
@@ -5,8 +5,6 @@
items, though within Fabric itself only ``Process`` objects are used/supported.
"""
-from pprint import pprint
-from Crypto import Random
import time
import Queue
@@ -61,7 +59,7 @@ def __len__(self):
Just going to use number of jobs as the JobQueue length.
"""
return self._num_of_jobs
-
+
def close(self):
"""
A sanity check, so that the need to care about new jobs being added in
@@ -171,12 +169,12 @@ def _advance_the_queue():
return results
-#### Sample
+#### Sample
def try_using(parallel_type):
"""
This will run the queue through it's paces, and show a simple way of using
- the job queue.
+ the job queue.
"""
def print_number(number):
@@ -191,17 +189,16 @@ def print_number(number):
elif parallel_type == "threading":
from threading import Thread as Bucket
-
# Make a job_queue with a bubble of len 5, and have it print verbosely
jobs = JobQueue(5)
jobs._debug = True
# Add 20 procs onto the stack
for x in range(20):
jobs.append(Bucket(
- target = print_number,
- args = [x],
- kwargs = {},
+ target=print_number,
+ args=[x],
+ kwargs={},
))
# Close up the queue and then start it's execution
View
17 fabric/main.py
@@ -9,8 +9,7 @@
to individuals leveraging Fabric as a library, should be kept elsewhere.
"""
-from collections import defaultdict
-from operator import add, isMappingType
+from operator import isMappingType
from optparse import OptionParser
import os
import sys
@@ -20,7 +19,7 @@
from fabric import api, state, colors
from fabric.contrib import console, files, project
-from fabric.network import denormalize, disconnect_all, ssh
+from fabric.network import disconnect_all, ssh
from fabric.state import env_options
from fabric.tasks import Task, execute
from fabric.task_utils import _Dict, crawl
@@ -34,6 +33,7 @@
[]
)
+
# Module recursion cache
class _ModuleCache(object):
"""
@@ -263,7 +263,9 @@ def parse_options():
# Initialize
#
- parser = OptionParser(usage="fab [options] <command>[:arg1,arg2=val2,host=foo,hosts='h1;h2',...] ...")
+ parser = OptionParser(
+ usage=("fab [options] <command>"
+ "[:arg1,arg2=val2,host=foo,hosts='h1;h2',...] ..."))
#
# Define options that don't become `env` vars (typically ones which cause
@@ -334,12 +336,14 @@ def parse_options():
opts, args = parser.parse_args()
return parser, opts, args
+
def _is_task(name, value):
"""
Is the object a task as opposed to e.g. a dict or int?
"""
return is_classic_task((name, value)) or is_task_object(value)
+
def _sift_tasks(mapping):
tasks, collections = [], []
for name, value in mapping.iteritems():
@@ -351,6 +355,7 @@ def _sift_tasks(mapping):
collections = sorted(collections)
return tasks, collections
+
def _task_names(mapping):
"""
Flatten & sort task names in a breadth-first fashion.
@@ -417,6 +422,7 @@ def _nested_list(mapping, level=1):
COMMANDS_HEADER = "Available commands"
NESTED_REMINDER = " (remember to call as module.[...].task)"
+
def list_commands(docstring, format_):
"""
Print all found commands/tasks, then exit. Invoked with ``-l/--list.``
@@ -557,9 +563,6 @@ def update_output_levels(show, hide):
state.output[key] = False
-from fabric.tasks import _parallel_tasks
-
-
def main():
"""
Main command-line execution loop.
View
5 fabric/network.py
@@ -8,9 +8,7 @@
import getpass
import os
import re
-import threading
import time
-import select
import socket
import sys
@@ -120,7 +118,7 @@ def ssh_config(host_string=None):
with open(path) as fd:
conf.parse(fd)
env._ssh_config = conf
- except IOError, e:
+ except IOError:
abort("Unable to load SSH config file '%s'" % path)
host = parse_host_string(host_string or env.host_string)['host']
return env._ssh_config.lookup(host)
@@ -202,6 +200,7 @@ def to_dict(host_string):
'user': user, 'host': host, 'port': port, 'host_string': host_string
}
+
def from_dict(arg):
return join_host_strings(arg['user'], arg['host'], arg['port'])
View
16 fabric/operations.py
@@ -7,7 +7,6 @@
import os
import os.path
import re
-import stat
import subprocess
import sys
import time
@@ -20,13 +19,14 @@
from fabric.sftp import SFTP
from fabric.state import env, connections, output, win32, default_channel
from fabric.thread_handling import ThreadHandler
-from fabric.utils import abort, indent, warn, puts, handle_prompt_abort, error, _pty_size
-
-# For terminal size logic below
-if not win32:
- import fcntl
- import termios
- import struct
+from fabric.utils import (
+ abort,
+ error,
+ handle_prompt_abort,
+ indent,
+ _pty_size,
+ warn,
+)
def _shell_escape(string):
View
2 fabric/sftp.py
@@ -57,7 +57,7 @@ def glob(self, path):
return ret
def walk(self, top, topdown=True, onerror=None, followlinks=False):
- from os.path import join, isdir, islink
+ from os.path import join
# We may not have read permission for top, in which case we can't get a
# list of the files the directory contains. os.path.walk always
View
4 fabric/state.py
@@ -65,7 +65,7 @@ def _rc_path():
rc_file
)
-default_port = '22' # hurr durr
+default_port = '22' # hurr durr
default_ssh_config_path = '~/.ssh/config'
# Options/settings which exist both as environment keys and which can be set on
@@ -131,7 +131,7 @@ def _rc_path():
help="comma-separated list of hosts to operate on"
),
- make_option('-i',
+ make_option('-i',
action='append',
dest='key_filename',
metavar='PATH',
View
3 fabric/task_utils.py
@@ -1,11 +1,11 @@
from fabric.utils import abort, indent
-from fabric import state
# For attribute tomfoolery
class _Dict(dict):
pass
+
def _crawl(name, mapping):
"""
``name`` of ``'a.b.c'`` => ``mapping['a']['b']['c']``
@@ -16,6 +16,7 @@ def _crawl(name, mapping):
return value
return _crawl(rest, value)
+
def crawl(name, mapping):
try:
result = _crawl(name, mapping)

0 comments on commit a0ac19b

Please sign in to comment.
Something went wrong with that request. Please try again.