From f0962041ae0b297feff4871efeff626d4234987a Mon Sep 17 00:00:00 2001 From: Gaetan Semet Date: Tue, 22 Jul 2014 17:24:51 +0200 Subject: [PATCH 1/7] Update readme and travis build Signed-off-by: Gaetan Semet --- .travis.yml | 9 +++++---- README.rst | 20 ++++++++++++++------ dev.sh | 3 +++ 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4e8ff588..a8db665b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,10 +8,11 @@ virtualenv: compiler: - gcc before_install: - - sudo apt-get install -qq build-essential python autoconf - - sudo apt-get install -qq gnome-common gtk-doc-tools libglib2.0-dev libgtk2.0-dev libgconf2-dev - - sudo apt-get install -qq python-gtk2 python-gtk2-dev python-vte python-appindicator - - sudo apt-get install -qq python3-dev + - sudo apt-get update -qq + - sudo apt-get install -qq --fix-missing build-essential python autoconf + - sudo apt-get install -qq --fix-missing gnome-common gtk-doc-tools libglib2.0-dev libgtk2.0-dev libgconf2-dev + - sudo apt-get install -qq --fix-missing python-gtk2 python-gtk2-dev python-vte python-appindicator + - sudo apt-get install -qq --fix-missing python3-dev install: - pip install -r python-requirements.txt --use-mirrors - find /usr/include diff --git a/README.rst b/README.rst index cf636675..e1244608 100644 --- a/README.rst +++ b/README.rst @@ -72,7 +72,7 @@ dependencies:: sudo apt-get build-dep guake -For manual dependency listing (Ubuntu 13.10):: +For compiling from these sources, please install the following packages (Ubuntu 13.10):: sudo apt-get install build-essential python autoconf sudo apt-get install gnome-common gtk-doc-tools libglib2.0-dev libgtk2.0-dev libgconf2-dev @@ -90,6 +90,10 @@ For Fedora 19 and above, Guake is available in the official repositories and can sudo yum install guake +For compiling from these sources, please install the following packages (Fedora 19):: + + TBD + ArchLinux --------- @@ -98,8 +102,12 @@ and installed by running:: sudo pacman -S guake +For compiling from these sources, please install the following packages (TBD):: + + TBD + Compilation -~~~~~~~~~~~~ +~~~~~~~~~~~ We are using an autotools based installation, so if you got the source of guake from a release tarball, please do the following:: @@ -110,10 +118,10 @@ of guake from a release tarball, please do the following:: $ sudo make install If you receive a message asking you if you have installed -guake.schemas properly when launching guake, it means that your +``guake.schemas`` properly when launching guake, it means that your default sysconfdir is different from the one chosen by autotools. To -fix that, you probably have to append the param `--sysconfdir=/etc' to -your `./configure' call, like this:: +fix that, you probably have to append the param ``--sysconfdir=/etc`` to +your ``./configure`` call, like this:: $ ./configure --sysconfdir=/etc && make @@ -122,7 +130,7 @@ file by hand by doing the following:: # GCONF_CONFIG_SOURCE="" gconftool-2 --makefile-install-rule data/guake.schemas -For more install details, please read the `INSTALL` file. +For more install details, please read the ``INSTALL`` file. Git hook ~~~~~~~~ diff --git a/dev.sh b/dev.sh index 78501c32..d997af60 100755 --- a/dev.sh +++ b/dev.sh @@ -1,5 +1,8 @@ #!/bin/sh +# This script is used by the main developer to quickly compile and install the current version +# of Guake sources. Nothing say it will work directly on your environment. Use with caution! + [ ! -f configure ] && ./autogen.sh make && sudo make install && gconftool-2 --install-schema-file=/usr/local/etc/gconf/schemas/guake.schemas || exit 1 From 82a7d5a318a3b385b282ed94d523b0616635f749 Mon Sep 17 00:00:00 2001 From: Gaetan Semet Date: Tue, 22 Jul 2014 17:42:39 +0200 Subject: [PATCH 2/7] validate.sh can validate all codes Signed-off-by: Gaetan Semet --- validate.sh | 89 ++++++++++++++++++++++++++++++----------------------- 1 file changed, 50 insertions(+), 39 deletions(-) diff --git a/validate.sh b/validate.sh index a1a51815..ab2cda68 100755 --- a/validate.sh +++ b/validate.sh @@ -1,5 +1,21 @@ #! /bin/bash -REVRANGE="$1..HEAD" + +if [[ ! -z $1 ]] && [[ $1 == "--help" ]]; then + echo "USAGE: validate.sh [oldrev [--quick]]" + echo " This script will test a set of patches (oldrev..HEAD) for basic acceptability as a patch" + echo " Run it in an activated virtualenv with the current Buildbot installed, as well as" + echo " sphinx, pyflakes, mock, and so on" + echo "To use a different directory for tests, pass TRIALTMP=/path as an env variable" + echo "if --quick is passed validate will skip unit tests and concentrate on coding style" + echo + echo "If no argument is given, all files from current directory will be inspected" + exit 1 +fi + +REVRANGE= +if [ ! -z $1 ]; then + REVRANGE="$1..HEAD" +fi TRIAL_TESTS= # some colors @@ -12,15 +28,6 @@ LTCYAN="$_ESC[1;36m" YELLOW="$_ESC[1;33m" NORM="$_ESC[0;0m" -if [ $# -eq 0 ]; then - echo "USAGE: validate.sh oldrev [--quick]" - echo " This script will test a set of patches (oldrev..HEAD) for basic acceptability as a patch" - echo " Run it in an activated virtualenv with the current Buildbot installed, as well as" - echo " sphinx, pyflakes, mock, and so on" - echo "To use a different directory for tests, pass TRIALTMP=/path as an env variable" - echo "if --quick is passed validate will skip unit tests and concentrate on coding style" - exit 1 -fi status() { echo "${LTCYAN}-- ${*} --${NORM}" @@ -65,39 +72,43 @@ run_tests() { trial --reporter text ${TEMP_DIRECTORY_OPT} ${TRIAL_TESTS} } -if ! git diff --no-ext-diff --quiet --exit-code; then - not_ok "changed files in working copy" +if [ -z $REVRANGE ]; then + py_files=$(find . -name '*.py' | grep -E '(src\/guake$|\.py$)') +else + + if ! git diff --no-ext-diff --quiet --exit-code; then + not_ok "changed files in working copy" + if $slow; then + exit 1 + fi + fi + # get a list of changed files, used below; this uses a tempfile to work around + # shell behavior when piping to 'while' + tempfile=$(mktemp) + trap 'rm -f ${tempfile}' 1 2 3 15 + git diff --name-only $REVRANGE | grep -E '(src\/guake$|\.py$)' | grep -v '\(^master/\(contrib\|docs\)\|/setup\.py\)' > ${tempfile} + py_files=() + while read line; do + if test -f "${line}"; then + py_files+=($line) + fi + done < ${tempfile} + + echo "${MAGENTA}Validating the following commits:${NORM}" + git --no-pager log "$REVRANGE" --pretty=oneline || exit 1 + if $slow; then - exit 1 + status "running tests" + run_tests || not_ok "tests failed" fi + + status "checking formatting" + check_tabs && not_ok "$REVRANGE adds tabs" + + status "checking for release notes" + check_relnotes || warning "$REVRANGE does not add release notes" fi -# get a list of changed files, used below; this uses a tempfile to work around -# shell behavior when piping to 'while' -tempfile=$(mktemp) -trap 'rm -f ${tempfile}' 1 2 3 15 -git diff --name-only $REVRANGE | grep -E '(src\/guake$|\.py$)' | grep -v '\(^master/\(contrib\|docs\)\|/setup\.py\)' > ${tempfile} -py_files=() -while read line; do - if test -f "${line}"; then - py_files+=($line) - fi -done < ${tempfile} - -echo "${MAGENTA}Validating the following commits:${NORM}" -git --no-pager log "$REVRANGE" --pretty=oneline || exit 1 - -if $slow; then - status "running tests" - run_tests || not_ok "tests failed" -fi - -status "checking formatting" -check_tabs && not_ok "$REVRANGE adds tabs" - -status "checking for release notes" -check_relnotes || warning "$REVRANGE does not add release notes" - status "checking import module convention in modified files" RES=true for filename in ${py_files[@]}; do From cb3570c2fdf8c301928aa7033fb21e642c8e4756 Mon Sep 17 00:00:00 2001 From: Gaetan Semet Date: Tue, 22 Jul 2014 17:45:57 +0200 Subject: [PATCH 3/7] pylint: all code is validated now. Can be travis'ed now! Signed-off-by: Gaetan Semet --- doc/source/conf.py | 101 +++++++++++++++++------------------ src/common.py | 20 ++++--- src/dbusiface.py | 5 +- src/globalhotkeys/example.py | 3 +- src/gtk-theme-swatch.py | 92 ++++++++++++++++--------------- src/notifier.py | 4 +- src/print_gtk_colors.py | 17 +++--- src/simplegladeapp.py | 47 ++++++++-------- src/tests/test_quit_edit.py | 3 +- 9 files changed, 151 insertions(+), 141 deletions(-) diff --git a/doc/source/conf.py b/doc/source/conf.py index a6492bea..b63fac46 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -12,17 +12,16 @@ # serve to show the default. import os -import sys # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. -#sys.path.insert(0, os.path.abspath('.')) +# sys.path.insert(0, os.path.abspath('.')) # -- General configuration ----------------------------------------------------- # If your documentation needs a minimal Sphinx version, state it here. -#needs_sphinx = '1.0' +# needs_sphinx = '1.0' # Add any Sphinx extension module names here, as strings. They can be extensions # coming with Sphinx (named 'sphinx.ext.*') or your custom ones. @@ -35,7 +34,7 @@ templates_path = ['_templates'] source_suffix = '.rst' # The encoding of source files. -#source_encoding = 'utf-8-sig' +# source_encoding = 'utf-8-sig' # The master toctree document. master_doc = 'index' @@ -55,37 +54,37 @@ release = '0.5.0' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. -#language = None +# language = None # There are two options for replacing |today|: either, you set today to some # non-false value, then it is used: -#today = '' +# today = '' # Else, today_fmt is used as the format for a strftime call. -#today_fmt = '%B %d, %Y' +# today_fmt = '%B %d, %Y' # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. exclude_patterns = [] # The reST default role (used for this markup: `text`) to use for all documents. -#default_role = None +# default_role = None # If true, '()' will be appended to :func: etc. cross-reference text. -#add_function_parentheses = True +# add_function_parentheses = True # If true, the current module name will be prepended to all description # unit titles (such as .. function::). -#add_module_names = True +# add_module_names = True # If true, sectionauthor and moduleauthor directives will be shown in the # output. They are ignored by default. -#show_authors = False +# show_authors = False # The name of the Pygments (syntax highlighting) style to use. pygments_style = 'sphinx' # A list of ignored prefixes for module index sorting. -#modindex_common_prefix = [] +# modindex_common_prefix = [] # -- Options for HTML output --------------------------------------------------- @@ -101,26 +100,26 @@ else: # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the # documentation. -#html_theme_options = {} +# html_theme_options = {} # Add any paths that contain custom themes here, relative to this directory. -#html_theme_path = [] +# html_theme_path = [] # The name for this set of Sphinx documents. If None, it defaults to # " v documentation". -#html_title = None +# html_title = None # A shorter title for the navigation bar. Default is the same as html_title. -#html_short_title = None +# html_short_title = None # The name of an image file (relative to this directory) to place at the top # of the sidebar. -#html_logo = None +# html_logo = None # The name of an image file (within the static path) to use as favicon of the # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 # pixels large. -#html_favicon = None +# html_favicon = None # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, @@ -129,44 +128,44 @@ html_static_path = ['_static'] # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, # using the given strftime format. -#html_last_updated_fmt = '%b %d, %Y' +# html_last_updated_fmt = '%b %d, %Y' # If true, SmartyPants will be used to convert quotes and dashes to # typographically correct entities. -#html_use_smartypants = True +# html_use_smartypants = True # Custom sidebar templates, maps document names to template names. -#html_sidebars = {} +# html_sidebars = {} # Additional templates that should be rendered to pages, maps page names to # template names. -#html_additional_pages = {} +# html_additional_pages = {} # If false, no module index is generated. -#html_domain_indices = True +# html_domain_indices = True # If false, no index is generated. -#html_use_index = True +# html_use_index = True # If true, the index is split into individual pages for each letter. -#html_split_index = False +# html_split_index = False # If true, links to the reST sources are added to the pages. -#html_show_sourcelink = True +# html_show_sourcelink = True # If true, "Created using Sphinx" is shown in the HTML footer. Default is True. -#html_show_sphinx = True +# html_show_sphinx = True # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. -#html_show_copyright = True +# html_show_copyright = True # If true, an OpenSearch description file will be output, and all pages will # contain a tag referring to it. The value of this option must be the # base URL from which the finished HTML is served. -#html_use_opensearch = '' +# html_use_opensearch = '' # This is the file name suffix for HTML files (e.g. ".xhtml"). -#html_file_suffix = None +# html_file_suffix = None # Output file base name for HTML help builder. htmlhelp_basename = 'guakeonlinedoc' @@ -175,42 +174,42 @@ htmlhelp_basename = 'guakeonlinedoc' # -- Options for LaTeX output -------------------------------------------------- latex_elements = { -# The paper size ('letterpaper' or 'a4paper'). -#'papersize': 'letterpaper', + # The paper size ('letterpaper' or 'a4paper'). + #'papersize': 'letterpaper', -# The font size ('10pt', '11pt' or '12pt'). -#'pointsize': '10pt', + # The font size ('10pt', '11pt' or '12pt'). + #'pointsize': '10pt', -# Additional stuff for the LaTeX preamble. -#'preamble': '', + # Additional stuff for the LaTeX preamble. + #'preamble': '', } # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, author, documentclass [howto/manual]). latex_documents = [ - ('index', 'guakeonlinehelp.tex', u'Guake Terminal Documentation', - u'Gaetan Semet', 'manual'), + ('index', 'guakeonlinehelp.tex', u'Guake Terminal Documentation', + u'Gaetan Semet', 'manual'), ] # The name of an image file (relative to this directory) to place at the top of # the title page. -#latex_logo = None +# latex_logo = None # For "manual" documents, if this is true, then toplevel headings are parts, # not chapters. -#latex_use_parts = False +# latex_use_parts = False # If true, show page references after internal links. -#latex_show_pagerefs = False +# latex_show_pagerefs = False # If true, show URL addresses after external links. -#latex_show_urls = False +# latex_show_urls = False # Documents to append as an appendix to all manuals. -#latex_appendices = [] +# latex_appendices = [] # If false, no module index is generated. -#latex_domain_indices = True +# latex_domain_indices = True # -- Options for manual page output -------------------------------------------- @@ -223,7 +222,7 @@ man_pages = [ ] # If true, show URL addresses after external links. -#man_show_urls = False +# man_show_urls = False # -- Options for Texinfo output ------------------------------------------------ @@ -232,16 +231,16 @@ man_pages = [ # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ - ('index', 'guakeonlinehelp', u'Guake Terminal Documentation', - u'Gaetan Semet', 'guakeonlinehelp', 'One line description of project.', - 'Miscellaneous'), + ('index', 'guakeonlinehelp', u'Guake Terminal Documentation', + u'Gaetan Semet', 'guakeonlinehelp', 'One line description of project.', + 'Miscellaneous'), ] # Documents to append as an appendix to all manuals. -#texinfo_appendices = [] +# texinfo_appendices = [] # If false, no module index is generated. -#texinfo_domain_indices = True +# texinfo_domain_indices = True # How to display URL addresses: 'footnote', 'no', or 'inline'. -#texinfo_show_urls = 'footnote' +# texinfo_show_urls = 'footnote' diff --git a/src/common.py b/src/common.py index b265330a..37f15c8f 100644 --- a/src/common.py +++ b/src/common.py @@ -19,16 +19,12 @@ Boston, MA 02110-1301 USA """ from __future__ import absolute_import -import gtk import gconf -import sys -import os -import locale import gettext -import time -import subprocess -import re +import gtk import guake.globals +import os +import sys # Internationalization purposes. _ = gettext.gettext @@ -37,10 +33,11 @@ __all__ = ['_', 'ShowableError', 'test_gconf', 'pixmapfile', 'gladefile', 'hexify_color', 'get_binaries_from_path'] + class ShowableError(Exception): def __init__(self, title, msg, exit_code=1): d = gtk.MessageDialog(type=gtk.MESSAGE_ERROR, - buttons=gtk.BUTTONS_CLOSE) + buttons=gtk.BUTTONS_CLOSE) d.set_markup('%s' % title) d.format_secondary_markup(msg) d.run() @@ -48,26 +45,31 @@ class ShowableError(Exception): if exit_code != -1: sys.exit(exit_code) + def test_gconf(): c = gconf.client_get_default() return c.dir_exists('/apps/guake') + def pixmapfile(x): f = os.path.join(guake.globals.IMAGE_DIR, x) if not os.path.exists(f): raise IOError('No such file or directory: %s' % f) return os.path.abspath(f) + def gladefile(x): f = os.path.join(guake.globals.GLADE_DIR, x) if not os.path.exists(f): raise IOError('No such file or directory: %s' % f) return os.path.abspath(f) + def hexify_color(c): h = lambda x: hex(x).replace('0x', '').zfill(4) return '#%s%s%s' % (h(c.red), h(c.green), h(c.blue)) + def get_binaries_from_path(compiled_re): ret = [] for i in os.environ.get('PATH', '').split(os.pathsep): @@ -77,9 +79,11 @@ def get_binaries_from_path(compiled_re): ret.append(os.path.join(i, j)) return ret + def shell_quote(text): """ quote text (filename) for inserting into a shell """ return r"\'".join("'%s'" % p for p in text.split("'")) + def clamp(value, lower, upper): return max(min(value, upper), lower) diff --git a/src/dbusiface.py b/src/dbusiface.py index cea84a0c..ad4e6e8e 100755 --- a/src/dbusiface.py +++ b/src/dbusiface.py @@ -18,15 +18,14 @@ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA """ import dbus -import dbus.service import dbus.glib -import gtk -import guake.common +import dbus.service dbus.glib.threads_init() DBUS_PATH = '/org/guake/RemoteControl' DBUS_NAME = 'org.guake.RemoteControl' + class DbusManager(dbus.service.Object): def __init__(self, guakeinstance): self.guake = guakeinstance diff --git a/src/globalhotkeys/example.py b/src/globalhotkeys/example.py index d3b63535..82cec3bd 100644 --- a/src/globalhotkeys/example.py +++ b/src/globalhotkeys/example.py @@ -62,8 +62,9 @@ if you want to test your program when it shoud say to the user that the binding failed, you can simply use this program to bind the key that you're running. Because you can bind a key once. """ -import gtk import globalhotkeys +import gtk + def hammer(*args): print args diff --git a/src/gtk-theme-swatch.py b/src/gtk-theme-swatch.py index 18e120a8..2584da29 100644 --- a/src/gtk-theme-swatch.py +++ b/src/gtk-theme-swatch.py @@ -8,11 +8,12 @@ import pygtk pygtk.require('2.0') + class ThemeSwatch(gtk.DrawingArea): - SWATCH_SIZE = 50 #swatch size - SWATCH_GAP = 5 #gap - SWATCH_LABEL_SIZE = 10 #text size + SWATCH_SIZE = 50 # swatch size + SWATCH_GAP = 5 # gap + SWATCH_LABEL_SIZE = 10 # text size STYLES = ( "fg", @@ -23,14 +24,14 @@ class ThemeSwatch(gtk.DrawingArea): "text", "base", "text_aa" - ) + ) STYLE_STATES = { - gtk.STATE_NORMAL:"normal", - gtk.STATE_ACTIVE:"active", - gtk.STATE_PRELIGHT:"prelight", - gtk.STATE_SELECTED:"selected", - gtk.STATE_INSENSITIVE:"insensitive" - } + gtk.STATE_NORMAL: "normal", + gtk.STATE_ACTIVE: "active", + gtk.STATE_PRELIGHT: "prelight", + gtk.STATE_SELECTED: "selected", + gtk.STATE_INSENSITIVE: "insensitive" + } def __init__(self): gtk.DrawingArea.__init__(self) @@ -38,32 +39,36 @@ class ThemeSwatch(gtk.DrawingArea): @classmethod def get_min_size(cls): - w = (1+len(cls.STYLE_STATES))*(cls.SWATCH_SIZE + cls.SWATCH_GAP) - h = (1+len(cls.STYLES))*(cls.SWATCH_SIZE + cls.SWATCH_GAP) - return w,h + w = (1 + len(cls.STYLE_STATES)) * (cls.SWATCH_SIZE + cls.SWATCH_GAP) + h = (1 + len(cls.STYLES)) * (cls.SWATCH_SIZE + cls.SWATCH_GAP) + return w, h def color_to_cairo_rgba(self, c, a=1): - return c.red/65535.0, c.green/65535.0, c.blue/65535.0, a + return c.red / 65535.0, c.green / 65535.0, c.blue / 65535.0, a def draw_rect(self, x, y, w, h, color): cr = self.context cr.rectangle(x, y, w, h) cr.set_source_rgba( - *self.color_to_cairo_rgba(color) - ) + *self.color_to_cairo_rgba(color) + ) cr.fill() def draw_round_rect(self, x, y, w, h, color, r=15): cr = self.context cr.set_source_rgba( - *self.color_to_cairo_rgba(color) - ) + *self.color_to_cairo_rgba(color) + ) - cr.move_to(x+r,y) - cr.line_to(x+w-r,y); cr.curve_to(x+w,y,x+w,y,x+w,y+r) - cr.line_to(x+w,y+h-r); cr.curve_to(x+w,y+h,x+w,y+h,x+w-r,y+h) - cr.line_to(x+r,y+h); cr.curve_to(x,y+h,x,y+h,x,y+h-r) - cr.line_to(x,y+r); cr.curve_to(x,y,x,y,x+r,y) + cr.move_to(x + r, y) + cr.line_to(x + w - r, y) + cr.curve_to(x + w, y, x + w, y, x + w, y + r) + cr.line_to(x + w, y + h - r) + cr.curve_to(x + w, y + h, x + w, y + h, x + w - r, y + h) + cr.line_to(x + r, y + h) + cr.curve_to(x, y + h, x, y + h, x, y + h - r) + cr.line_to(x, y + r) + cr.curve_to(x, y, x, y, x + r, y) cr.close_path() cr.fill() @@ -84,53 +89,54 @@ class ThemeSwatch(gtk.DrawingArea): cr = self.context rect = self.get_allocation() - s = self.SWATCH_SIZE #swatch size - g = self.SWATCH_GAP #gap - t = self.SWATCH_LABEL_SIZE #text size + s = self.SWATCH_SIZE # swatch size + g = self.SWATCH_GAP # gap + t = self.SWATCH_LABEL_SIZE # text size - x = rect.x+g + x = rect.x + g y = rect.y - #draw style state labels, x axis - #cr.rotate(-30) + # draw style state labels, x axis + # cr.rotate(-30) cr.set_font_size(t) - for state,name in self.STYLE_STATES.items(): + for state, name in self.STYLE_STATES.items(): cr.set_source_rgb(0, 0, 0) - cr.move_to(x+0.5, y+s/2+t/2) + cr.move_to(x + 0.5, y + s / 2 + t / 2) cr.show_text(name) - x += g+s - #cr.rotate(30) + x += g + s + # cr.rotate(30) y += s - x = rect.x+g + x = rect.x + g for name in self.STYLES: colors = getattr(self.style, name, None) if colors: for state in self.STYLE_STATES: color = colors[state] - #self.draw_rect(x, y, s, s, color) + # self.draw_rect(x, y, s, s, color) self.draw_round_rect(x, y, s, s, color) - print "[%7s,%11s]" % (name, self.STYLE_STATES[state]) , + print "[%7s,%11s]" % (name, self.STYLE_STATES[state]), - x += g+s + x += g + s - #draw style labels, y axis + # draw style labels, y axis cr.set_source_rgb(0, 0, 0) - cr.move_to(x+g, y+s/2+t/2) + cr.move_to(x + g, y + s / 2 + t / 2) cr.show_text(name) - x = rect.x+g - y += g+s + x = rect.x + g + y += g + s print "" + def main(): window = gtk.Window() theme = ThemeSwatch() window.set_size_request( - *theme.get_min_size() - ) + *theme.get_min_size() + ) window.add(theme) window.connect("destroy", gtk.main_quit) diff --git a/src/notifier.py b/src/notifier.py index 7be60b2f..4a46a3d4 100644 --- a/src/notifier.py +++ b/src/notifier.py @@ -24,9 +24,9 @@ pynotify.init("Guake") __all__ = ['show_message'] -RETRY_INTERVAL = 3 # seconds +RETRY_INTERVAL = 3 # seconds -retry_limit = 5 # tries +retry_limit = 5 # tries def show_message(brief, body=None, icon=None): diff --git a/src/print_gtk_colors.py b/src/print_gtk_colors.py index 225c6999..bbc6f2d6 100644 --- a/src/print_gtk_colors.py +++ b/src/print_gtk_colors.py @@ -1,16 +1,17 @@ #!/usr/bin/env python -import pygtk import gtk -def format_color_string( Color ): - return "%s %s %s" % (Color.red /256, Color.green/256, Color.blue/256) +def format_color_string(color): + return "%s %s %s" % (color.red / 256, color.green / 256, color.blue / 256) -def print_hex_color( Color ): - return "#" + hex(Color.red/256)[2:] + hex(Color.green/256)[2:] + hex(Color.blue/256)[2:] -def format_color_key( key, Color): - return "\"%s\"=\"%s\" (%s)\n" % (key, format_color_string( Color ), print_hex_color( Color )) +def print_hex_color(color): + return "#" + hex(color.red / 256)[2:] + hex(color.green / 256)[2:] + hex(color.blue / 256)[2:] + + +def format_color_key(key, color): + return "\"%s\"=\"%s\" (%s)\n" % (key, format_color_string(color), print_hex_color(color)) invisible1 = gtk.Invisible() style1 = invisible1.style @@ -18,7 +19,7 @@ style1 = invisible1.style button1 = gtk.Button() buttonstyle = button1.style -scroll1 = gtk.VScrollbar() +scroll1 = gtk.VScrollbar() scrollbarstyle = scroll1.style menu1 = gtk.Menu() diff --git a/src/simplegladeapp.py b/src/simplegladeapp.py index 2d7c4041..ef51eb08 100644 --- a/src/simplegladeapp.py +++ b/src/simplegladeapp.py @@ -31,20 +31,21 @@ import pygtk pygtk.require('2.0') import os -import sys import re +import sys -import tokenize import gtk import gtk.glade -import weakref import inspect +import tokenize +import weakref __version__ = "1.0" __author__ = 'Sandino "tigrux" Flores-Moreno' + def bindtextdomain(app_name, locale_dir=None): - """ + """ Bind the domain represented by app_name to the locale directory locale_dir. It has the effect of loading translations, enabling applications for different languages. @@ -55,7 +56,7 @@ def bindtextdomain(app_name, locale_dir=None): locale_dir: a directory with locales like locale_dir/lang_isocode/LC_MESSAGES/app_name.mo If omitted or None, then the current binding for app_name is used. - """ + """ try: import locale import gettext @@ -65,10 +66,10 @@ def bindtextdomain(app_name, locale_dir=None): gettext.textdomain(app_name) gtk.glade.bindtextdomain(app_name, locale_dir) gtk.glade.textdomain(app_name) - gettext.install(app_name, locale_dir, unicode = 1) - except (IOError,locale.Error), e: + gettext.install(app_name, locale_dir, unicode=1) + except (IOError, locale.Error), e: print "Warning", app_name, e - __builtins__.__dict__["_"] = lambda x : x + __builtins__.__dict__["_"] = lambda x: x class SimpleGladeApp(object): @@ -100,15 +101,15 @@ class SimpleGladeApp(object): It is useful to set attributes of new instances, for example: glade_app = SimpleGladeApp("ui.glade", foo="some value", bar="another value") sets two attributes (foo and bar) to glade_app. - """ + """ if os.path.isfile(path): self.glade_path = path else: - glade_dir = os.path.dirname( sys.argv[0] ) + glade_dir = os.path.dirname(sys.argv[0]) self.glade_path = os.path.join(glade_dir, path) for key, value in kwargs.items(): try: - setattr(self, key, weakref.proxy(value) ) + setattr(self, key, weakref.proxy(value)) except TypeError: setattr(self, key, value) self.glade = None @@ -151,7 +152,7 @@ class SimpleGladeApp(object): callbacks_proxy: an instance with methods as code of callbacks. It means it has methods like on_button1_clicked, on_entry1_activate, etc. - """ + """ self.glade.signal_autoconnect(callbacks_proxy) def normalize_names(self): @@ -166,12 +167,12 @@ class SimpleGladeApp(object): for widget in self.get_widgets(): widget_name = gtk.Widget.get_name(widget) prefixes_name_l = widget_name.split(":") - prefixes = prefixes_name_l[ : -1] + prefixes = prefixes_name_l[: -1] widget_api_name = prefixes_name_l[-1] widget_api_name = "_".join(re.findall(tokenize.Name, widget_api_name)) gtk.Widget.set_name(widget, widget_api_name) if hasattr(self, widget_api_name): - raise AttributeError("instance %s already has an attribute %s" % (self,widget_api_name)) + raise AttributeError("instance %s already has an attribute %s" % (self, widget_api_name)) else: setattr(self, widget_api_name, widget) if prefixes: @@ -191,18 +192,18 @@ class SimpleGladeApp(object): prefix_actions_proxy: An instance with methods as prefix actions. It means it has methods like prefix_foo, prefix_bar, etc. - """ + """ prefix_s = "prefix_" prefix_pos = len(prefix_s) - is_method = lambda t : callable( t[1] ) - is_prefix_action = lambda t : t[0].startswith(prefix_s) - drop_prefix = lambda (k,w): (k[prefix_pos:],w) + is_method = lambda t: callable(t[1]) + is_prefix_action = lambda t: t[0].startswith(prefix_s) + drop_prefix = lambda (k, w): (k[prefix_pos:], w) members_t = inspect.getmembers(prefix_actions_proxy) methods_t = filter(is_method, members_t) prefix_actions_t = filter(is_prefix_action, methods_t) - prefix_actions_d = dict( map(drop_prefix, prefix_actions_t) ) + prefix_actions_d = dict(map(drop_prefix, prefix_actions_t)) for widget in self.get_widgets(): prefixes = gtk.Widget.get_data(widget, "prefixes") @@ -213,8 +214,8 @@ class SimpleGladeApp(object): prefix_action(widget) def custom_handler(self, - glade, function_name, widget_name, - str1, str2, int1, int2): + glade, function_name, widget_name, + str1, str2, int1, int2): """ Generic handler for creating custom widgets, internally used to enable custom widgets (custom widgets of glade). @@ -268,7 +269,7 @@ class SimpleGladeApp(object): """ widget.destroy() - def gtk_window_activate_default(self, window, *args): + def gtk_window_activate_default(self, widget, *args): """ Predefined callback. The default widget of the window is activated. @@ -316,7 +317,7 @@ class SimpleGladeApp(object): """ Quit processing events. The default implementation calls gtk.main_quit() - + Useful for applications that needs a non gtk main loop. For example, applications based on gstreamer needs to override this method with gst.main_quit() diff --git a/src/tests/test_quit_edit.py b/src/tests/test_quit_edit.py index d2345ccb..59520d5b 100644 --- a/src/tests/test_quit_edit.py +++ b/src/tests/test_quit_edit.py @@ -1,7 +1,6 @@ -import unittest import guake +import unittest -print os.sys class TestQuickEdit(unittest.TestCase): def testMatch(self): From 7e3dae5a56ef5d40140c8b16d5762fc0b782f868 Mon Sep 17 00:00:00 2001 From: Gaetan Semet Date: Tue, 22 Jul 2014 17:48:33 +0200 Subject: [PATCH 4/7] pip: needed tools for validate on travis Signed-off-by: Gaetan Semet --- python-requirements.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/python-requirements.txt b/python-requirements.txt index e69de29b..e4ae69a8 100644 --- a/python-requirements.txt +++ b/python-requirements.txt @@ -0,0 +1,4 @@ +pylint +pep8 +autopep8 +pyflakes From e3b105ba911ffd62a58f945747cbb0fc3993baf7 Mon Sep 17 00:00:00 2001 From: Gaetan Semet Date: Tue, 22 Jul 2014 17:49:00 +0200 Subject: [PATCH 5/7] Execute validate.sh on travis Signed-off-by: Gaetan Semet --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index a8db665b..2bbcd962 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,4 +17,5 @@ install: - pip install -r python-requirements.txt --use-mirrors - find /usr/include script: + - ./validate.sh - ./autogen.sh && ./configure && make From 70e3007bd7dee25a7e04090c26098fff6e5497c8 Mon Sep 17 00:00:00 2001 From: Gaetan Semet Date: Tue, 22 Jul 2014 18:18:11 +0200 Subject: [PATCH 6/7] fix for travis Signed-off-by: Gaetan Semet --- doc/source/conf.py | 6 +++--- pylintrc | 3 ++- validate.sh | 4 +++- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/doc/source/conf.py b/doc/source/conf.py index b63fac46..49e15f9e 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -175,13 +175,13 @@ htmlhelp_basename = 'guakeonlinedoc' latex_elements = { # The paper size ('letterpaper' or 'a4paper'). - #'papersize': 'letterpaper', + # 'papersize': 'letterpaper', # The font size ('10pt', '11pt' or '12pt'). - #'pointsize': '10pt', + # 'pointsize': '10pt', # Additional stuff for the LaTeX preamble. - #'preamble': '', + # 'preamble': '', } # Grouping the document tree into LaTeX files. List of tuples diff --git a/pylintrc b/pylintrc index c0a3c57c..65edeb28 100644 --- a/pylintrc +++ b/pylintrc @@ -139,7 +139,8 @@ disable= W1001, W1402, W1501, - superfluous-parens + superfluous-parens, + bad-continuation, [REPORTS] diff --git a/validate.sh b/validate.sh index ab2cda68..1eb736b1 100755 --- a/validate.sh +++ b/validate.sh @@ -73,7 +73,9 @@ run_tests() { } if [ -z $REVRANGE ]; then - py_files=$(find . -name '*.py' | grep -E '(src\/guake$|\.py$)') + py_files=$(find . -name '*.py' | grep -E '(src\/guake$|\.py$)' | grep -v 'src/globals.py') + echo "Validating files: " + echo $py_files else if ! git diff --no-ext-diff --quiet --exit-code; then From eff4d252939ce905ed69ad9e6bc08245cb96f8bc Mon Sep 17 00:00:00 2001 From: Gaetan Semet Date: Tue, 22 Jul 2014 18:37:24 +0200 Subject: [PATCH 7/7] changes with new version of autopep8 Signed-off-by: Gaetan Semet --- src/common.py | 1 + src/dbusiface.py | 1 + src/prefs.py | 4 ++++ src/tests/test_quit_edit.py | 1 + 4 files changed, 7 insertions(+) diff --git a/src/common.py b/src/common.py index 37f15c8f..e92f7a7f 100644 --- a/src/common.py +++ b/src/common.py @@ -35,6 +35,7 @@ __all__ = ['_', 'ShowableError', 'test_gconf', class ShowableError(Exception): + def __init__(self, title, msg, exit_code=1): d = gtk.MessageDialog(type=gtk.MESSAGE_ERROR, buttons=gtk.BUTTONS_CLOSE) diff --git a/src/dbusiface.py b/src/dbusiface.py index ad4e6e8e..6a3fc067 100755 --- a/src/dbusiface.py +++ b/src/dbusiface.py @@ -27,6 +27,7 @@ DBUS_NAME = 'org.guake.RemoteControl' class DbusManager(dbus.service.Object): + def __init__(self, guakeinstance): self.guake = guakeinstance self.bus = dbus.SessionBus() diff --git a/src/prefs.py b/src/prefs.py index 83141112..1f2a3ae2 100644 --- a/src/prefs.py +++ b/src/prefs.py @@ -160,6 +160,7 @@ PALETTES = [ class PrefsCallbacks(object): + """Holds callbacks that will be used in the PrefsDialg class. """ @@ -347,8 +348,10 @@ class PrefsCallbacks(object): class PrefsDialog(SimpleGladeApp): + """The Guake Preferences dialog. """ + def __init__(self): """Setup the preferences dialog interface, loading images, adding filters to file choosers and connecting some signals. @@ -857,6 +860,7 @@ class PrefsDialog(SimpleGladeApp): class KeyEntry(object): + def __init__(self, keycode, mask): self.keycode = keycode self.mask = mask diff --git a/src/tests/test_quit_edit.py b/src/tests/test_quit_edit.py index 59520d5b..d8f1d43e 100644 --- a/src/tests/test_quit_edit.py +++ b/src/tests/test_quit_edit.py @@ -3,6 +3,7 @@ import unittest class TestQuickEdit(unittest.TestCase): + def testMatch(self): print guake