Skip to content

Instantly share code, notes, and snippets.

View hvelarde's full-sized avatar

Héctor Velarde hvelarde

View GitHub Profile
@hvelarde
hvelarde / pre-commit
Created June 5, 2012 22:14
PEP 8 pre-commit hook
#!/bin/sh
# Modified from kevincal version in https://gist.github.com/810399
# The following is a list of the most common PEP 8 errors and warnings; to
# skip some just add them to the IGNORE variable (comma separated):
# E111 indentation is not a multiple of four
# E123 closing bracket does not match indentation of opening bracket's line
# E201 whitespace after '('
# E202 whitespace before ')'
@hvelarde
hvelarde / .travis.yml
Created August 8, 2012 16:35
Sample Travis CI configuration file to run tests for Plone add-ons
language: python
python: "2.7"
install:
- python bootstrap.py -c travis.cfg
- bin/buildout -c travis.cfg -q
script: bin/test
@hvelarde
hvelarde / travis.cfg
Created August 8, 2012 16:41
Sample buildout configuration file to run tests for Plone add-ons
[buildout]
extends =
http://svn.plone.org/svn/collective/buildout/plonetest/test-4.x.cfg
parts = test
package-name = your.package
package-extras = [test]
#test-eggs = Pillow
@hvelarde
hvelarde / gist:3470516
Created August 25, 2012 20:18
AttributeError: __getitem__
Error in test test_create_dexterity (plone.api.tests.test_content.TestPloneApiContent)
Traceback (most recent call last):
File "/home/hvelarde/Python/python2.7/lib/python2.7/unittest/case.py", line 327, in run
testMethod()
File "/home/hvelarde/plone-py2.6/plone/api/src/plone/api/tests/test_content.py", line 98, in test_create_dexterity
container=folder, type='Dexterity Document', id='test-document')
File "/home/hvelarde/plone-py2.6/plone/api/src/plone/api/content.py", line 61, in create
content = container[new_id]
AttributeError: __getitem__
@hvelarde
hvelarde / coverage.sh
Created November 8, 2012 19:16
Test coverage checker
#! /bin/sh
# checks for report created with createzopecoverage and evaluate the result
# default minimum coverage is 80%
DEFAULT=80
REPORT="coverage/reports/all.html"
if [ "$1" -ge 0 ] && [ "$1" -le 100 ]; then
MINIMUM=$1
else
@hvelarde
hvelarde / gist:7931259
Created December 12, 2013 16:56
collective.cover API draft methods
# -*- coding: utf-8 -*-
import json
def get_tiles_from_layout(layout):
"""Traverse a layout tree and return a list of tiles on it.
:param layout: a JSON object describing the layout
:type layout: list
(python-2.7)# hvelarde@nanovac (master u=) ~/collective/cover
# git shortlog -s | sort -nr
697 hvelarde
312 Juan Pablo Giménez
91 Héctor Velarde
78 Franco Pellegrini
76 Marcos F. Romero
71 quimera
71 Cleber J Santos
66 Gonzalo Almeida
@hvelarde
hvelarde / github3.py example
Last active December 27, 2017 12:40
Getting your contributions on a GitHub organization using github3.py to access the GitHub API.
>>> user, password = 'hvelarde', 'password'
>>> from github3 import login
>>> g = login(user, password=password)
>>> o = g.organization('collective')
>>> g.ratelimit_remaining
3369
>>> my_stats = []
>>> for r in o.iter_repos():
... for c in r.iter_contributor_statistics():
... if user in repr(c.author):
@hvelarde
hvelarde / pep257.cfg
Created May 1, 2014 00:42
Add support for docstring style checker on buildout
[buildout]
parts = pep257
[pep257]
recipe = zc.recipe.egg
eggs = pep257
entry-points = pep257=pep257:main
arguments = *pep257.parse_options()
@hvelarde
hvelarde / gist:82dab21a803f8d68a217
Last active August 29, 2015 14:03
Using bpython and IPython
eggs += bpython
bin/instance debug
import bpython; bpython.embed(locals_=locals())
eggs += IPython
bin/instance debug