Skip to content

Commit

Permalink
Update all except the main winshell module itself for (near-)PEP8 com…
Browse files Browse the repository at this point in the history
…pliance
  • Loading branch information
tjguk committed Mar 31, 2012
1 parent 037e1d9 commit ffe7e6a
Show file tree
Hide file tree
Showing 9 changed files with 609 additions and 603 deletions.
8 changes: 4 additions & 4 deletions docs/cookbook/recycle-bin/undelete_by_criteria.py
Expand Up @@ -4,7 +4,7 @@
import winshell

midnight = datetime.datetime.today().replace(hour=0, minute=0, second=0)
for item in winshell.recycle_bin ():
if fnmatch.fnmatch(os.path.basename(item.original_filename()), "*.txt"):
if item.recycle_date() >= midnight:
print("About to undelete %r" % item)
for item in winshell.recycle_bin():
if fnmatch.fnmatch(os.path.basename(item.original_filename()), "*.txt"):
if item.recycle_date() >= midnight:
print("About to undelete %r" % item)
8 changes: 4 additions & 4 deletions docs/cookbook/shortcuts/read_existing.py
Expand Up @@ -3,8 +3,8 @@
import winshell

for lnk in glob.glob(os.path.join(winshell.programs(), "*.lnk")):
shortcut = winshell.shortcut(lnk)
shortcut.dump()
break
shortcut = winshell.shortcut(lnk)
shortcut.dump()
break
else:
print("None found")
print("None found")
38 changes: 19 additions & 19 deletions docs/cookbook/shortcuts/walk_program_tree.py
Expand Up @@ -5,27 +5,27 @@

user_programs = winshell.programs()
for dirpath, dirnames, filenames in os.walk(user_programs):
relpath = dirpath[1 + len(user_programs):]
shortcuts.setdefault(
relpath, []
).extend(
[winshell.shortcut(os.path.join(dirpath, f)) for f in filenames]
)
relpath = dirpath[1 + len(user_programs):]
shortcuts.setdefault(
relpath, []
).extend(
[winshell.shortcut(os.path.join(dirpath, f)) for f in filenames]
)

all_programs = winshell.programs(common=1)
for dirpath, dirnames, filenames in os.walk(all_programs):
relpath = dirpath[1 + len(all_programs):]
shortcuts.setdefault(
relpath, []
).extend(
[winshell.shortcut(os.path.join(dirpath, f)) for f in filenames]
)
relpath = dirpath[1 + len(all_programs):]
shortcuts.setdefault(
relpath, []
).extend(
[winshell.shortcut(os.path.join(dirpath, f)) for f in filenames]
)

for relpath, lnks in sorted(shortcuts.items()):
level = relpath.count("\\")
if level == 0:
print("")
print("%s+ %s" %(" " * level, relpath))
for lnk in lnks:
name, _ = os.path.splitext(os.path.basename(lnk.lnk_filepath))
print("%s* %s -> %s" % (" " * (level + 1), name, lnk.path))
level = relpath.count("\\")
if level == 0:
print("")
print("%s+ %s" % (" " * level, relpath))
for lnk in lnks:
name, _ = os.path.splitext(os.path.basename(lnk.lnk_filepath))
print("%s* %s -> %s" % (" " * (level + 1), name, lnk.path))
6 changes: 3 additions & 3 deletions generate-propkeys.py
@@ -1,8 +1,8 @@
import os, sys
import re

TEMPLATE = re.compile ("DEFINE_PROPERTYKEY\(PKEY_(\w+), ([0-9A-Fx, ]+)\)")
TEMPLATE = re.compile("DEFINE_PROPERTYKEY\(PKEY_(\w+), ([0-9A-Fx, ]+)\)")

source = r"C:\Program Files\Microsoft SDKs\Windows\v7.0\Include\propkey.h"
for a, b in TEMPLATE.findall (open (source).read ()):
print [i.strip () for i in b.split (",")]
for a, b in TEMPLATE.findall(open(source).read()):
print [i.strip() for i in b.split(",")]
44 changes: 22 additions & 22 deletions setup.py
Expand Up @@ -3,15 +3,15 @@
import __winshell_version__ as __version__

classifiers = [
'Development Status :: 5 - Production/Stable',
'Environment :: Win32 (MS Windows)',
'Intended Audience :: Developers',
'Intended Audience :: System Administrators',
'License :: OSI Approved :: MIT License',
'Operating System :: Microsoft :: Windows',
'Topic :: System :: Systems Administration',
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 3",
'Development Status :: 5 - Production/Stable',
'Environment :: Win32 (MS Windows)',
'Intended Audience :: Developers',
'Intended Audience :: System Administrators',
'License :: OSI Approved :: MIT License',
'Operating System :: Microsoft :: Windows',
'Topic :: System :: Systems Administration',
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 3",
]

#
Expand All @@ -21,19 +21,19 @@
# is the compromise:
#
try:
long_description = open ("README.rst").read ()
open ("README", "w").write (long_description)
long_description = open("README.rst").read()
open("README", "w").write(long_description)
except (OSError, IOError):
long_description = ""
long_description = ""

setup (
name = "winshell",
version = __version__.__VERSION__ + __version__.__RELEASE__,
description = "Windows shell functions",
author = "Tim Golden",
author_email = "mail@timgolden.me.uk",
url = "https://github.com/tjguk/winshell",
license = "http://www.opensource.org/licenses/mit-license.php",
py_modules = ["winshell", "__winshell_version__"],
long_description=long_description
setup(
name="winshell",
version=__version__.__VERSION__ + __version__.__RELEASE__,
description="Windows shell functions",
author="Tim Golden",
author_email="mail@timgolden.me.uk",
url="https://github.com/tjguk/winshell",
license="http://www.opensource.org/licenses/mit-license.php",
py_modules=["winshell", "__winshell_version__"],
long_description=long_description
)
61 changes: 31 additions & 30 deletions tag.py
Expand Up @@ -4,42 +4,43 @@
PROJECT = "winshell"
VERSION_FILE = "__%s_version__.py" % PROJECT

def git (command):
if isinstance (command, basestring):
command = [command]
return subprocess.check_output (["git.cmd"] + command)

VERSION_BLOCK = """
# -*- coding: UTF8 -*-
__VERSION__ = "%(tag)s"
__RELEASE__ = ""
"""


def git (command):
if isinstance(command, basestring):
command = [command]
return subprocess.check_output(["git.cmd"] + command)

def main (tag):
#
# Add stuff to changelog
#
git ("checkout master")
git ("pull")
with open (VERSION_FILE, "w") as f:
f.write (VERSION_BLOCK % tag)
git (["add", VERSION_FILE])
git (["commit", "-m", "Tagged master for v%s" % tag])

git ("checkout stable")
git ("pull")
git ("merge master")
git (["tag", tag])

git ("checkout master")
git ("push --all")
git ("push --tags")

subprocess.call ("python setup.py sdist")

#
# Reset version.py to next version-dev
#
#
# Add stuff to changelog
#
git("checkout master")
git("pull")
with open(VERSION_FILE, "w") as f:
f.write(VERSION_BLOCK % tag)
git(["add", VERSION_FILE])
git(["commit", "-m", "Tagged master for v%s" % tag])

git("checkout stable")
git("pull")
git("merge master")
git(["tag", tag])

git("checkout master")
git("push --all")
git("push --tags")

subprocess.call("python setup.py sdist")

#
# Reset version.py to next version-dev
#

if __name__ == '__main__':
main (*sys.argv[1:])
main(*sys.argv[1:])
15 changes: 7 additions & 8 deletions test_base.py
@@ -1,15 +1,14 @@
# -*- coding: UTF8 -*-
import unittest

class TestCase (unittest.TestCase):

def assertEqualCI (self, s1, s2, *args, **kwargs):
self.assertEqual (s1.lower (), s2.lower (), *args, **kwargs)
class TestCase(unittest.TestCase):

def assertIs (self, item1, item2, *args, **kwargs):
self.assertTrue (item1 is item2, *args, **kwargs)
def assertEqualCI(self, s1, s2, *args, **kwargs):
self.assertEqual(s1.lower(), s2.lower(), *args, **kwargs)

def assertIsInstance (self, item, klass, *args, **kwargs):
self.assertTrue (isinstance (item, klass), *args, **kwargs)
def assertIs(self, item1, item2, *args, **kwargs):
self.assertTrue(item1 is item2, *args, **kwargs)

###
def assertIsInstance(self, item, klass, *args, **kwargs):
self.assertTrue(isinstance(item, klass), *args, **kwargs)

0 comments on commit ffe7e6a

Please sign in to comment.