Commit ef03c3b0 authored by Guilhem Saurel's avatar Guilhem Saurel

doctest

parent 2877f78b
......@@ -5,6 +5,7 @@ verify_ssl = true
[dev-packages]
yapf = "*"
ipython = "*"
[packages]
ndh = "*"
......
{
"_meta": {
"hash": {
"sha256": "355611a88891e4227aa6a4454f08a3d2ebe4d6db9459028a03818d028c93a751"
"sha256": "ebc0e3256d27ac65f467c43f53c16fc14ff58f693d277ee43b17892592d33474"
},
"pipfile-spec": 6,
"requires": {},
......@@ -192,6 +192,106 @@
}
},
"develop": {
"backcall": {
"hashes": [
"sha256:38ecd85be2c1e78f77fd91700c76e14667dc21e2713b63876c0eb901196e01e4",
"sha256:bbbf4b1e5cd2bdb08f915895b51081c041bac22394fdfcfdfbe9f14b77c08bf2"
],
"version": "==0.1.0"
},
"decorator": {
"hashes": [
"sha256:41fa54c2a0cc4ba648be4fd43cff00aedf5b9465c9bf18d64325bc225f08f760",
"sha256:e3a62f0520172440ca0dcc823749319382e377f37f140a0b99ef45fecb84bfe7"
],
"version": "==4.4.2"
},
"ipython": {
"hashes": [
"sha256:ca478e52ae1f88da0102360e57e528b92f3ae4316aabac80a2cd7f7ab2efb48a",
"sha256:eb8d075de37f678424527b5ef6ea23f7b80240ca031c2dd6de5879d687a65333"
],
"index": "pypi",
"version": "==7.13.0"
},
"ipython-genutils": {
"hashes": [
"sha256:72dd37233799e619666c9f639a9da83c34013a73e8bbc79a7a6348d93c61fab8",
"sha256:eb2e116e75ecef9d4d228fdc66af54269afa26ab4463042e33785b887c628ba8"
],
"version": "==0.2.0"
},
"jedi": {
"hashes": [
"sha256:cd60c93b71944d628ccac47df9a60fec53150de53d42dc10a7fc4b5ba6aae798",
"sha256:df40c97641cb943661d2db4c33c2e1ff75d491189423249e989bcea4464f3030"
],
"version": "==0.17.0"
},
"parso": {
"hashes": [
"sha256:158c140fc04112dc45bca311633ae5033c2c2a7b732fa33d0955bad8152a8dd0",
"sha256:908e9fae2144a076d72ae4e25539143d40b8e3eafbaeae03c1bfe226f4cdf12c"
],
"version": "==0.7.0"
},
"pexpect": {
"hashes": [
"sha256:0b48a55dcb3c05f3329815901ea4fc1537514d6ba867a152b581d69ae3710937",
"sha256:fc65a43959d153d0114afe13997d439c22823a27cefceb5ff35c2178c6784c0c"
],
"markers": "sys_platform != 'win32'",
"version": "==4.8.0"
},
"pickleshare": {
"hashes": [
"sha256:87683d47965c1da65cdacaf31c8441d12b8044cdec9aca500cd78fc2c683afca",
"sha256:9649af414d74d4df115d5d718f82acb59c9d418196b7b4290ed47a12ce62df56"
],
"version": "==0.7.5"
},
"prompt-toolkit": {
"hashes": [
"sha256:563d1a4140b63ff9dd587bda9557cffb2fe73650205ab6f4383092fb882e7dc8",
"sha256:df7e9e63aea609b1da3a65641ceaf5bc7d05e0a04de5bd45d05dbeffbabf9e04"
],
"version": "==3.0.5"
},
"ptyprocess": {
"hashes": [
"sha256:923f299cc5ad920c68f2bc0bc98b75b9f838b93b599941a6b63ddbc2476394c0",
"sha256:d7cc528d76e76342423ca640335bd3633420dc1366f258cb31d05e865ef5ca1f"
],
"version": "==0.6.0"
},
"pygments": {
"hashes": [
"sha256:647344a061c249a3b74e230c739f434d7ea4d8b1d5f3721bc0f3558049b38f44",
"sha256:ff7a40b4860b727ab48fad6360eb351cc1b33cbf9b15a0f689ca5353e9463324"
],
"version": "==2.6.1"
},
"six": {
"hashes": [
"sha256:236bdbdce46e6e6a3d61a337c0f8b763ca1e8717c03b369e87a7ec7ce1319c0a",
"sha256:8f3cd2e254d8f793e7f3d6d9df77b92252b52637291d0f0da013c76ea2724b6c"
],
"version": "==1.14.0"
},
"traitlets": {
"hashes": [
"sha256:70b4c6a1d9019d7b4f6846832288f86998aa3b9207c6821f3578a6a6a467fe44",
"sha256:d023ee369ddd2763310e4c3eae1ff649689440d4ae59d7485eb4cfbbe3e359f7"
],
"version": "==4.3.3"
},
"wcwidth": {
"hashes": [
"sha256:cafe2186b3c009a04067022ce1dcd79cb38d8d65ee4f4791b8888d6599d1bbe1",
"sha256:ee73862862a156bf77ff92b09034fc4825dd3af9cf81bc5b360668d425f3c5f1"
],
"version": "==0.1.9"
},
"yapf": {
"hashes": [
"sha256:712e23c468506bf12cadd10169f852572ecc61b266258422d45aaf4ad7ef43de",
......
......@@ -16,6 +16,9 @@ INVALID_MAILS = ('localhost', 'none', 'noreply', 'example')
def slugify_with_dots(value):
"""
slugify a name but keep dots
>>> slugify_with_dots('C’est la fête :3. yay.')
'cest-la-fete-3.-yay.'
"""
value = unicodedata.normalize('NFKD', value).encode('ascii', 'ignore').decode('ascii')
value = re.sub(r'[^\w\s\.-]', '', value).strip().lower()
......@@ -36,6 +39,12 @@ def api_next(source, req):
def domain(url):
"""
Extracts the domain of an url
>>> domain('https://gitlab.laas.fr/pipo')
'gitlab.laas.fr'
>>> domain('gitlab.laas.fr/pipo')
'gitlab.laas.fr'
"""
if '://' in url or url.startswith('//'):
url = url.split('//')[1]
......@@ -43,6 +52,12 @@ def domain(url):
def domain_link(url):
"""
get a link to an url, showing the domain name.
>>> domain_link('https://gitlab.laas.fr/pipo')
'<a href="https://gitlab.laas.fr/pipo">gitlab.laas.fr</a>'
"""
dn = domain(url)
return mark_safe(f'<a href="{url}">{dn}</a>')
......@@ -65,4 +80,15 @@ def invalid_mail(mail):
def valid_name(name):
"""
Replace dashes and underscores by spaces, and lowercase.
>>> valid_name('TALOS_Metapkg-ros_control_sot')
'talos metapkg ros control sot'
"""
return name.replace('_', ' ').replace('-', ' ').lower()
if __name__ == "__main__":
import doctest
doctest.testmod()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment