Humanstxt

Humanstxt is a python library for dealing with humans.txt.

Note

Humanstxt only works with vailed humans.txt ( like template in http://humanstxt.org/Standard.html)

Quickstart

Using humanstxt is quite simple.You can use parse() to turn humans.txt text into HumansTxt and dealing with it like a dict

from humanstxt import parse

txt = """
/* TEAM */
    Founder & Developer: Jacky Chan
    Contact: linux_china [at] hotmail.com
    Weibo: @linux_china
    Blog: http://intellij.org.cn/blog
    From: HangZhou, ZheJiang, China
    University: Beijing Institute of Technology
    Degree: Bachelor

/* THANKS */
    humans.txt Founder: Abel Cabans
    Site: http://www.humanstxt.org

/* SITE */
    Last update: 2013/01/23
    Language: Chinese
    Doctype: HTML5
    Standards: HTML5, CSS3
    Components: RequireJS, JQuery, Backbone, BootStrap
    Software: ImageMagick, PhantomJS
    IDE: IntelliJ IDEA

        __  __                                _______  ________
       / / / /_  ______ ___  ____ _____  ____/_  __/ |/ /_  __/
      / /_/ / / / / __ `__ \/ __ `/ __ \/ ___// /  |   / / /
     / __  / /_/ / / / / / / /_/ / / / (__  )/ /  /   | / /
    /_/ /_/\__,_/_/ /_/ /_/\__,_/_/ /_/____//_/  /_/|_|/_/
"""

humanstxt = parse(txt)

print(humanstxt.keys())  # ['team', 'thanks', 'site', 'description']

print(humanstxt["team"]["Contact"])  # linux_china@hotmail.com

print(str(humanstxt))  # the same as ``txt`` above

Attention

Humanstxt will replace [at] with @ ( whtsky [at] gmail.com => whtsky@gmail.com )

Note

You can turn a HumansTxt into a vailed humans.txt text via str .

API

humanstxt.parse(text)

Parse the humans.txt into an HumansTxt class.

Example

from humanstxt import parse

txt = """
/* TEAM */
    Founder & Developer: Jacky Chan
    Contact: linux_china [at] hotmail.com
    Weibo: @linux_china
    Blog: http://intellij.org.cn/blog
    From: HangZhou, ZheJiang, China
    University: Beijing Institute of Technology
    Degree: Bachelor

/* THANKS */
    humans.txt Founder: Abel Cabans
    Site: http://www.humanstxt.org

/* SITE */
    Last update: 2013/01/23
    Language: Chinese
    Doctype: HTML5
    Standards: HTML5, CSS3
    Components: RequireJS, JQuery, Backbone, BootStrap
    Software: ImageMagick, PhantomJS
    IDE: IntelliJ IDEA

        __  __                                _______  ________
       / / / /_  ______ ___  ____ _____  ____/_  __/ |/ /_  __/
      / /_/ / / / / __ `__ \/ __ `/ __ \/ ___// /  |   / / /
     / __  / /_/ / / / / / / /_/ / / / (__  )/ /  /   | / /
    /_/ /_/\__,_/_/ /_/ /_/\__,_/_/ /_/____//_/  /_/|_|/_/
"""

humanstxt = parse(txt)
Parameters:text – the text of humans.txt
Returns:HumansTxt
class humanstxt.HumansTxt(*args, **kwds)

Use HumansTxt class like a dict.

Example

from humanstxt import parse

txt = """
/* TEAM */
    Founder & Developer: Jacky Chan
    Contact: linux_china [at] hotmail.com
    Weibo: @linux_china
    Blog: http://intellij.org.cn/blog
    From: HangZhou, ZheJiang, China
    University: Beijing Institute of Technology
    Degree: Bachelor

/* THANKS */
    humans.txt Founder: Abel Cabans
    Site: http://www.humanstxt.org

/* SITE */
    Last update: 2013/01/23
    Language: Chinese
    Doctype: HTML5
    Standards: HTML5, CSS3
    Components: RequireJS, JQuery, Backbone, BootStrap
    Software: ImageMagick, PhantomJS
    IDE: IntelliJ IDEA

        __  __                                _______  ________
       / / / /_  ______ ___  ____ _____  ____/_  __/ |/ /_  __/
      / /_/ / / / / __ `__ \/ __ `/ __ \/ ___// /  |   / / /
     / __  / /_/ / / / / / / /_/ / / / (__  )/ /  /   | / /
    /_/ /_/\__,_/_/ /_/ /_/\__,_/_/ /_/____//_/  /_/|_|/_/
"""

humanstxt = parse(txt)

print(humanstxt.keys())  # ['team', 'thanks', 'site', 'description']

HumansTxt will replace [at] to @

print(humanstxt["team"]["Contact"])  # linux_china@hotmail.com

You can turn HumansTxt into a vailed humans.txt via str

print(str(humanstxt))  # the same as ``txt`` above
Fork me on GitHub