This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# | |
# PythonOnWheels migration to backup a DB Table | |
# Using the Model's to_json method. | |
# Usage: python do_migrate -j pow_backup_migration_job.py -d up | |
# will backup a Posts Table in this example. | |
# Replace the Post with any other model and it will backup | |
# your model. (make sure you backup linked data (like external stored BLOBS) | |
# as well. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## | |
## | |
## This file was autogenerated by python_on_wheels. | |
## But you can safely edit this file. It will only be overwritten | |
## if you use the -f (--force) option on generate_scaffold. | |
## | |
## 2013-03-29 | |
## | |
## inherits the layout defined in config/pow.py as default_layout |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Info: python 3.x | |
# datetime json serializer | |
# author: khz june/2014 | |
# www.pythononwheels.org | |
# | |
# | |
import datetime | |
import json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import csv | |
import json | |
import sys | |
# | |
# | |
# converts csv to json | |
# fieldnames are taken from the first line of the csv input file | |
# | |
# khz / 2014 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Test string comparison of string tuples | |
# python 3.4 | |
# using difflib. | |
# | |
# see also: http://stackoverflow.com/questions/36643618/scoring-consistency-within-dataset | |
# khz 04/2016 | |
# | |
import difflib | |
import random |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*-: coding utf-8 -*- | |
""" | |
This module is a proposal to add python's dataclass support to cerberus. | |
See Issue: #397 | |
https://github.com/pyeve/cerberus/issues/397 | |
And road-map: | |
1.3 | |
Checklist: | |
The module dataclasses is implemented. This may get postponed 'til a following minor release. (#397) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# convert json data to a cerberus schema. | |
# Cerberus types see here: http://docs.python-cerberus.org/en/stable/validation-rules.html#type | |
# | |
# sampledata: https://www.json-generator.com/ | |
# | |
# this uses the first data element in a given json file to create | |
# a model(cerberus) schema from it. Trying to guess the right types (without too much effort) | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
schema = { | |
'title' : { 'type' : 'string', 'maxlength' : 35 }, | |
'text' : { 'type' : 'string' }, | |
'tags' : { 'type' : 'list', "default" : [] }, | |
"votes" : { "type" : "integer", "default" : 0 } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@relation.has_many("subtasks") | |
@relation.setup_sql_schema() | |
class Task(Base): | |
schema = { | |
'title' : { 'type' : 'string', 'maxlength' : 35 }, | |
'text' : { 'type' : 'string' }, | |
"votes" : { "type" : "integer", "default" : 0 } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@app.add_rest_routes("task") | |
class Task(BaseHandler): | |
# | |
# every pow handler automatically gets these RESTful routes | |
# when you add the : app.add_rest_routes() decorator. | |
# | |
# 1 GET /todo #=> list | |
# 2 GET /todo/<uuid:identifier> #=> show | |
# 3 GET /todo/new #=> new | |
# 4 GET /todo/<uuid:identifier>/edit #=> edit |
OlderNewer