Skip to content

Instantly share code, notes, and snippets.

View macagua's full-sized avatar
🏠
Working from home

Leonardo J. Caballero G. macagua

🏠
Working from home
View GitHub Profile
@macagua
macagua / gist:4942318
Created February 13, 2013 04:39
zopeskel configuration file for Buildout projects
# .zopeskel configuration file for Buildout projects
# This file can contain preferences for zopeskel.
# To do so, uncomment the lines that look like:
# variable_name = Default Value
[DEFAULT]
# Expert Mode? (What question mode would you like? (easy/expert/all)?)
expert_mode = easy
@macagua
macagua / gist:4722804
Created February 6, 2013 14:24
A setuptools configuration (setup.py) for define the package name
# the package name
name = 'collective.mypackage'
# get packages from the package name: '1.2.3' -> ['1','1.2','1.2.3']
>>> packages = [name.rsplit('.',x)[0] for x in reversed(range(len(name.split('.'))))]
>>> packages
['collective', 'collective.mypackage']
>>> # all except the last are treated as namespace_packages
>>> namespace_packages = packages[:-1]
>>> namespace_packages
['collective']
@macagua
macagua / gist:4709197
Last active December 12, 2015 03:48
A example for try to fixing user input from Python script
# -*- coding: utf8 -*-
print "Insisting on fixing user input"
first = 1
second = 2
third = 3
while 1:
try:
extra = input("What is the extra value? ")
@macagua
macagua / gist:4702326
Created February 3, 2013 16:09
Demo of a main menu for choose a option from a Python script.
# -*- coding: utf8 -*-
def menu():
''' Main menu to choose an item '''
chosen_element = 0;
print "#############################################################################"
print "######## ########"
print "######## My Company Super Client Number 1' ########"
@macagua
macagua / gist:4702250
Last active December 12, 2015 02:49
Cleanup action to a shell console from a Python script, is a example python script that simulate the cleanup action to a shell console, it do that to scroll the screen down lots of lines.
# -*- coding: utf8 -*-
def cls():
''' Python script main function '''
print "\n" * 100
if __name__ == '__main__':
''' Python script main function '''
@macagua
macagua / gist:4702161
Last active December 12, 2015 02:49
Terminating a Python script, is a example of terminate a Python script
# -*- coding: utf8 -*-
import sys
sys.exit()