Permalink
Browse files

PEP8 compliance fixes

  • Loading branch information...
1 parent ca33a9b commit 883dec6b9a999da1a8c49f6ab2a8559d730dcd39 @GaretJax committed Apr 14, 2012
Showing with 37 additions and 32 deletions.
  1. +24 −22 pytex/commands/building.py
  2. +7 −6 pytex/commands/init.py
  3. +2 −1 pytex/commands/templates.py
  4. +0 −1 pytex/monitors/fsevents.py
  5. +4 −2 pytex/monitors/pyinotify.py
View
@@ -24,14 +24,14 @@ def execute(self, args):
self.compile(tempdir, dest)
def mktempdir(self, tempdir):
- # Find every *.tex file in the source directory
- # Recreate the dir tree under tempdir for the dirname of each found *.tex file
+ # Find every *.tex file in the source directory to ecreate the dir
+ # tree under tempdir for the dirname of each found *.tex file
matches = set()
for root, dirnames, filenames in os.walk('.', topdown=False):
if root in matches:
- # If a subdirectory of root was already scheduled for creation
- # ignore root altogether
+ # If a subdirectory of root was already scheduled for
+ # creation ignore root altogether
continue
for f in filenames:
@@ -42,10 +42,10 @@ def mktempdir(self, tempdir):
head, tail = os.path.split(head)
break
- dirs = sorted(matches, key=len) # A lexicographic sort would work as well,
- # but sorting on the string length is more
- # efficient as the length is cached and
- # only integer comparisons are needed
+ # A lexicographic sort would work as well, but sorting on the
+ # string length is more efficient as the length is cached and
+ # only integer comparisons are needed
+ dirs = sorted(matches, key=len)
dirs = (os.path.join(tempdir, d) for d in dirs)
dirs = (os.path.realpath(d) for d in dirs)
@@ -88,11 +88,12 @@ class Watch(Compile):
def parser(self):
parser = self.parser_class()
- parser.add_argument('-i', '--initial', help='Execute a build before entering the watching loop', action='store_true')
+ parser.add_argument('-i', '--initial',
+ help='Execute a build before entering the watching loop',
+ action='store_true')
return parser
-
def execute(self, args):
base = os.path.realpath('.')
@@ -104,39 +105,40 @@ def execute(self, args):
dest = os.path.join(base, name + '.pdf')
def handler(event):
- relative = event.path[len(base)+1:]
+ relative = event.path[len(base) + 1:]
if event.path.startswith(tempdir):
- self.logger.debug('Ignoring \'{}\''.format(relative))
+ self.logger.debug('Ignoring {!r}'.format(relative))
return
if event.path == dest:
- self.logger.debug('Ignoring \'{}\''.format(relative))
+ self.logger.debug('Ignoring {!r}'.format(relative))
return
if os.path.basename(event.path).startswith('.'):
- self.logger.debug('Ignoring \'{}\''.format(relative))
+ self.logger.debug('Ignoring {!r}'.format(relative))
return
if os.path.basename(event.path).endswith('~'):
- self.logger.debug('Ignoring \'{}\''.format(relative))
+ self.logger.debug('Ignoring {!r}'.format(relative))
return
if os.path.isdir(event.path):
- self.logger.debug('Ignoring directory \'{}\''.format(relative))
+ self.logger.debug('Ignoring directory {!r}'.format(relative))
return
if isinstance(event, monitor.base.FileCreated):
if event.path.endswith('.tex'):
subdir = os.path.dirname(relative)
builddir = os.path.join(tempdir, subdir)
if not os.path.exists(builddir):
- # If a new .tex file was added ans the containing directory does not
- # exist in the build root, then create it
+ # If a new .tex file was added and the containing
+ # directory does not exist in the build root, create it
os.mkdir(builddir)
- self.logger.info("Added subdirectory {!r} to the build directory".format(subdir))
+ self.logger.info("Added subdirectory {!r} to the " \
+ "build directory".format(subdir))
- self.logger.info('Change detected at \'{}\', recompiling...'.format(
+ self.logger.info('Change detected at {!r}, recompiling...'.format(
relative))
self.compile(tempdir, dest)
@@ -168,11 +170,11 @@ class Clean(Command):
def parser(self):
parser = self.parser_class()
- parser.add_argument('--all', '-a', action='store_const', const=True, default=False)
+ parser.add_argument('--all', '-a', action='store_const', const=True,
+ default=False)
return parser
-
def execute(self, args):
tempdir = self.config.get('compilation', 'tempdir')
tempdir = os.path.realpath(tempdir)
View
@@ -1,6 +1,7 @@
from pytex.subcommands import Command
-import os, shutil
+import os
+import shutil
class Init(Command):
@@ -25,16 +26,16 @@ def execute(self, args):
self.logger.info("Creating new pytex document at '{}'".format(path))
- template_name = args.template or self.config.get('templates', 'default')
+ template = args.template or self.config.get('templates', 'default')
- self.logger.info("Selected template '{}'".format(template_name))
+ self.logger.info("Selected template '{}'".format(template))
- template = os.path.join(
+ template_dir = os.path.join(
os.path.expanduser(self.config.get('templates', 'directory')),
- template_name
+ template
)
- shutil.copytree(template, path)
+ shutil.copytree(template_dir, path)
print base
@@ -1,6 +1,7 @@
from pytex.subcommands import Command
-import os, sys
+import os
+import sys
class List(Command):
@@ -6,7 +6,6 @@
from pytex.monitors import base
-
class Stream(fsevents.Stream):
EVENT_MAPPINGS = {
@@ -6,7 +6,6 @@
from operator import attrgetter
-
class Stream(object):
EVENT_MAPPINGS = {
@@ -51,7 +50,10 @@ def start(self):
def monitor(self, path, callback):
stream = Stream(callback)
- mask = pyinotify.IN_CREATE | pyinotify.IN_MODIFY | pyinotify.IN_DELETE | pyinotify.IN_MOVED_FROM | pyinotify.IN_MOVED_TO | pyinotify.IN_ACCESS | pyinotify.IN_ATTRIB
+ mask = 0
+ mask |= pyinotify.IN_CREATE | pyinotify.IN_MODIFY | pyinotify.IN_DELETE
+ mask |= pyinotify.IN_MOVED_FROM | pyinotify.IN_MOVED_TO
+ mask |= pyinotify.IN_ACCESS | pyinotify.IN_ATTRIB
self.vm.add_watch(path, mask, stream.handle_event, rec=True)
def stop(self):

0 comments on commit 883dec6

Please sign in to comment.