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 -*- | |
from __future__ import absolute_import | |
from __future__ import unicode_literals | |
from django.db import models | |
from django.db.models.query import QuerySet | |
from django.core.urlresolvers import reverse | |
from django.utils.timezone import now | |
from django.utils.encoding import python_2_unicode_compatible |
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 -*- | |
""" | |
A collection of tasks for `Invoke`_ to help setting up a `Django`_ project | |
with `Gunicorn`_ on `Uberspace`_ accounts. | |
All information for this script has to be set in a JSON file | |
called ``settings.json`` in the same directory like this:: | |
{ |
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
deployments: | |
testing: | |
host: xyz.domain.tld | |
user: username | |
destination: /home/username/html/misc/path/ | |
sources: | |
- index.html | |
- img |
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
from django.core.exceptions import ValidationError | |
from django.utils.deconstruct import deconstructible | |
@deconstructible | |
class DateValidator(): | |
""" | |
Überprüft ob *ein Datum* vor oder nach einem gegebenen anderen Datum liegt. |
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
def add_image( | |
filenames, image_path, description='Cover', img_type=3, encoding=3 | |
): | |
""" | |
Adds an image to MP3 from *filenames*. | |
Args: | |
filenames (lits): paths to the MP3 | |
image_path (string): path to image file |
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
#!/usr/bin/env python | |
# -*- coding: UTF-8 -*- | |
""" | |
Ansible module to interact with `toast`_. | |
To use this from Ansible, copy it in your `library`_:: | |
cd path/to/library | |
git clone https://gist.github.com/brutus/ba3b110c3041777e2e976b61e924b18c toast |
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
""" | |
Quick check for `dry` / `ignore_dry` args to ``run``. | |
An ``invoke undry dry`` should result in:: | |
[undry] Hello World! | |
[undry] Hello other World! | |
echo '[isdry] Hello World!' | |
[isdry] Hello other World! |
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 pipeline collects yielded items to process them after a crawl finishes. | |
Overview | |
======== | |
For each yielded item :meth:`process_item` is called — and handles the storing | |
of items for later use. After all items are yielded, :meth:`close_spider` is | |
called and assembles the data from the previously collected items | |
(:meth:`assemble_collection`) and dumps the results (:meth:`dump_collection`). |
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
""" | |
Converts the *collation* and *character set* of a database using a Django | |
migration. Data in the tables is converted if needed. | |
""" | |
from django.db import migrations | |
def get_conversion_function(collation, character_set='utf8'): |
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
# Python Project | |
# | |
# Some targets to lint your code, run tests, builds and do some cleanup. | |
# Works fine with tox and Travis, etc. | |
# | |
# This setup assumes that you take care of the virtual environment setup | |
# yourself and that the needed requirements are installed. And also that | |
# you configure your tools. So edit your own `setup.cfg` or `.tox.ini` | |
# with the settings needed for the tools. | |
# |