Skip to content

Commit

Permalink
add tasks.py and fix docs.
Browse files Browse the repository at this point in the history
  • Loading branch information
thebjorn committed Jun 15, 2017
1 parent ce38741 commit f8fb37d
Show file tree
Hide file tree
Showing 24 changed files with 567 additions and 561 deletions.
2 changes: 1 addition & 1 deletion dk/dkimport.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def dkimport_star(modname, **kw):
from modname import *
Available **kw arguments:
Available ``**kw`` arguments:
filefilter A function that receives a filename (with extension
but without path) that should return True if the
Expand Down
44 changes: 22 additions & 22 deletions dk/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,28 @@
Usage::
>>> t = grid(emptyval=0)
>>> t.apply[:5,:5] = lambda v, (y,x):y*x
>>> t
0 0 0 0 0
0 1 2 3 4
0 2 4 6 8
0 3 6 9 12
0 4 8 12 16
>>> t.apply[:5,:5] = lambda v, p:v*2
>>> t
0 0 0 0 0
0 2 4 6 8
0 4 8 12 16
0 6 12 18 24
0 8 16 24 32
>>> t2 = grid.copy(t, lambda orig, (y,x):orig[y,x] / 2)
>>> t2
0 0 0 0 0
0 1 2 3 4
0 2 4 6 8
0 3 6 9 12
0 4 8 12 16
>>> t = grid(emptyval=0)
>>> t.apply[:5,:5] = lambda v, (y,x):y*x
>>> t
0 0 0 0 0
0 1 2 3 4
0 2 4 6 8
0 3 6 9 12
0 4 8 12 16
>>> t.apply[:5,:5] = lambda v, p:v*2
>>> t
0 0 0 0 0
0 2 4 6 8
0 4 8 12 16
0 6 12 18 24
0 8 16 24 32
>>> t2 = grid.copy(t, lambda orig, (y,x):orig[y,x] / 2)
>>> t2
0 0 0 0 0
0 1 2 3 4
0 2 4 6 8
0 3 6 9 12
0 4 8 12 16
"""
# pylint: disable=R0903,W0141,E1102,W0201
Expand Down
33 changes: 19 additions & 14 deletions dk/html/uhtml.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,12 @@ def quote(v):


def norm_attr_name(a):
"""_foo_bar => _foo_bar, class_ => class, max_height => max-height
>>> norm_attr_name(u'class_')
u'class'
>>> norm_attr_name(u'z_index')
u'z-index'
"""``_foo_bar => _foo_bar``, ``class_ => class``, ``max_height => max-height``
>>> norm_attr_name(u'class_')
u'class'
>>> norm_attr_name(u'z_index')
u'z-index'
"""
if a[0] == u'_':
return a
Expand All @@ -120,8 +121,9 @@ def norm_attr_name(a):
class xtag(object):
"""x(ml-style)tag: a tag without content or a closing tag.
E.g. <br/> would be xtag('br')
[2009-03-11] w3 validator complains that 4.01 loose should not use
<foo /> but <foo>.
.. note:: [2009-03-11] w3 validator complains that 4.01 loose should not
use <foo /> but <foo>.
"""
def __init__(self, tag_name, **kw):
self._attr = {}
Expand Down Expand Up @@ -195,7 +197,7 @@ class tag(xtag):
>> table(tr(td(i) for i in range(5)), tr(td(i**i) for i in range(5)))
NB: Attributes that conflict with Python keywords have an underline
appended, e.g.: mytag.class_ = ...
appended, e.g.: ``mytag.class_ = ...``
"""
def __init__(self, tag_name, *content, **kw):
xtag.__init__(self, tag_name, **kw)
Expand Down Expand Up @@ -461,12 +463,15 @@ def __init__(self, *cols):

def test_doctest():
"""
>>> br()
u'<br>'
>>> div('hello', b('world'))
u'<div>hello<b>world</b></div>\\n'
>>> print select(options=[u'a', u'b'], name='foo')
u'<select name="foo" id="id_foo"><option value="a">a</option>\\n<option value="b">b</option>\\n</select>'
::
>>> br()
u'<br>'
>>> div('hello', b('world'))
u'<div>hello<b>world</b></div>\\n'
>>> print select(options=[u'a', u'b'], name='foo')
u'<select name="foo" id="id_foo"><option value="a">a</option>\\n<option value="b">b</option>\\n</select>'
"""
import doctest
doctest.testmod()
Expand Down
4 changes: 2 additions & 2 deletions dk/identifiers/navn.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def forkort_navn(lengde, fornavn, etternavn):


def shorten_fname(length, fname):
"""Try to shorten the first-name `fname' to `length' characters
"""Try to shorten the first-name `fname` to `length` characters
(raise ValueError if we fail).
Algorithm: Consider the last of the person's first names and replace it
Expand All @@ -67,7 +67,7 @@ def shorten_fname(length, fname):


def shorten_lname(length, lname):
"""Try to shorten the last-name `lname' to `length' characters
"""Try to shorten the last-name `lname` to `length` characters
(raise ValueError if we fail).
Algorithm: Consider the first of the person's last names and replace it
Expand Down
15 changes: 8 additions & 7 deletions dk/ttcal/day.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,14 @@ def from_idtag(cls, tag):

@classmethod
def parse(cls, strval):
"""Parse date value from a string. Allowed syntax include::
yyyy-mm-dd, yyyy-m-dd, yyyy-mm-d, yyyy-m-d
dd-mm-yyyy, etc.
dd/mm/yyyy, ...
dd.mm.yyyy, ...
ddmmyyyy
"""Parse date value from a string. Allowed syntax include
::
yyyy-mm-dd, yyyy-m-dd, yyyy-mm-d, yyyy-m-d
dd-mm-yyyy, etc.
dd/mm/yyyy, ...
dd.mm.yyyy, ...
ddmmyyyy
"""
if not strval or not strval.strip():
Expand Down
13 changes: 8 additions & 5 deletions dk/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,16 @@ def root(): # FIXME: this is fubar (__file__ isn't near the root of the sour
return __file__.replace('\\', '/').rsplit('/', 1)[0]


def dkpath(pth=None): # FIXME: this doesn't work since srcpath doesn't work!
"""Usage::
# FIXME: this doesn't work since srcpath doesn't work!
def dkpath(pth=None):
"""Usage
::
dkpath() => (w:)/xxxxxxx/
=> (/home)/xxxxxxxx/
dkpath() => (w:)/xxxxxxx/
=> (/home)/xxxxxxxx/
dkpath('app/') => ../xxxxxxxx/app/
dkpath('app/') => ../xxxxxxxx/app/
"""
if not pth:
pth = ''
Expand Down
177 changes: 0 additions & 177 deletions docs/Makefile

This file was deleted.

0 comments on commit f8fb37d

Please sign in to comment.