From e0256b23307eae1cc8877ad857fe046ccfe92fac Mon Sep 17 00:00:00 2001 From: feng lv Date: Mon, 10 Sep 2018 13:54:12 +0800 Subject: [PATCH] translated --- ...reat Python libraries for side projects.md | 68 ------------------- ...reat Python libraries for side projects.md | 66 ++++++++++++++++++ 2 files changed, 66 insertions(+), 68 deletions(-) delete mode 100644 sources/tech/20180905 8 great Python libraries for side projects.md create mode 100644 translated/tech/20180905 8 great Python libraries for side projects.md diff --git a/sources/tech/20180905 8 great Python libraries for side projects.md b/sources/tech/20180905 8 great Python libraries for side projects.md deleted file mode 100644 index 3623c37c6d..0000000000 --- a/sources/tech/20180905 8 great Python libraries for side projects.md +++ /dev/null @@ -1,68 +0,0 @@ -ucasFL translating - -8 great Python libraries for side projects -====== - -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/python-programming-code-keyboard.png?itok=fxiSpmnd) - -We have a saying in the Python/Django world: We came for the language and stayed for the community. That is true for most of us, but something else that has kept us in the Python world is how easy it is to have an idea and quickly work through it over lunch or in a few hours at night. - -This month we're diving into Python libraries we love to use to quickly scratch those side-project or lunchtime itches. - -### To save data in a database on the fly: Dataset - -[Dataset][1] is our go-to library when we quickly want to collect data and save it into a database before we know what our final database tables will look like. Dataset has a simple, yet powerful API that makes it easy to put data in and sort it out later. - -Dataset is built on top of SQLAlchemy, so extending it will feel familiar. The underlying database models are a breeze to import into Django using Django's built-in [inspectdb][2] management command. This makes working with existing databases pretty painless. - -### To scrape data from web pages: Beautiful Soup - -[Beautiful Soup][3] (BS4 as of this writing) makes extracting information out of HTML pages easy. It's our go-to anytime we need to turn unstructured or loosely structured HTML into structured data. It's also great for working with XML data that might otherwise not be readable. - -### To work with HTTP content: Requests - -[Requests][4] is arguably one of the gold standard libraries for working with HTTP content. Anytime we need to consume an HTML page or even an API, Requests has us covered. It's also very well documented. - -### To write command-line utilities: Click - -When we need to write a native Python script, [Click][5] is our favorite library for writing command-line utilities. The API is straightforward, well thought out, and there are only a few patterns to remember. The docs are great, which makes looking up advanced features easy. - -### To name things: Python Slugify - -As we all know, naming things is hard. [Python Slugify][6] is a useful library for turning a title or description into a unique(ish) identifier. If you are working on a web project and you want to use SEO-friendly URLs, Python Slugify makes this easier. - -### To work with plugins: Pluggy - -[Pluggy][7] is relatively new, but it's also one of the best and easiest ways to add a plugin system to your existing application. If you have ever worked with pytest, you have used pluggy without knowing it. - -### To convert CSV files into APIs: Datasette - -[Datasette][8], not to be confused with Dataset, is an amazing tool for easily turning CSV files into full-featured read-only REST JSON APIs. Datasette has tons of features, including charting and geo (for creating interactive maps), and it's easy to deploy via a container or third-party web host. - -### To handle environment variables and more: Envparse - -If you need to parse environment variables because you don't want to save API keys, database credentials, or other sensitive information in your source code, then [envparse][9] is one of your best bets. Envparse handles environment variables, ENV files, variable types, and even pre- and post-processors (in case you want to ensure that a variable is always upper or lower case, for instance). - -Do you have a favorite Python library for side projects that's not on this list? Please share it in the comments. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/9/python-libraries-side-projects - -作者:[Jeff Triplett][a] -选题:[lujun9972](https://github.com/lujun9972) -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://opensource.com/users/laceynwilliams -[1]: https://dataset.readthedocs.io/en/latest/ -[2]: https://docs.djangoproject.com/en/2.1/ref/django-admin/#django-admin-inspectdb -[3]: https://www.crummy.com/software/BeautifulSoup/ -[4]: http://docs.python-requests.org/ -[5]: http://click.pocoo.org/5/ -[6]: https://github.com/un33k/python-slugify -[7]: https://pluggy.readthedocs.io/en/latest/ -[8]: https://github.com/simonw/datasette -[9]: https://github.com/rconradharris/envparse diff --git a/translated/tech/20180905 8 great Python libraries for side projects.md b/translated/tech/20180905 8 great Python libraries for side projects.md new file mode 100644 index 0000000000..26eb3e9a23 --- /dev/null +++ b/translated/tech/20180905 8 great Python libraries for side projects.md @@ -0,0 +1,66 @@ +8 个用于业余项目side projects的优秀 Python 库 +====== + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/python-programming-code-keyboard.png?itok=fxiSpmnd) + +在 Python/Django 的世界里有这样一个谚语:为语言而来,为社区而留。对绝大多数人来说的确是这样的,但是,还有一件事情使得我们一直停留在 Python 的世界里,不愿离开,那就是我们可以很容易地利用一顿午餐或晚上几个小时的时间,把一个想法快速地实现出来。 + +这个月,我们来探讨一些我们喜欢用来快速完成业余项目side projects或打发午餐时间的 Python 库。 + +### 在数据库中即时保存数据:Dataset + +当我们想要在不知道最终数据库表长什么样的情况下,快速收集数据并保存到数据库中的时候,[Dataset][1] 库将是我们的最佳选择。Dataset 库有一个简单但功能强大的 API,因此我们可以很容易的把数据保存下来,之后再进行排序。 + +Dataset 建立在 SQLAlchemy 之上,所以如果需要对它进行扩展,你会感到非常熟悉。使用 Django 内建的 [inspectdb][2] 管理命令可以很容易地把底层数据库模型导入 Django 中,这使得和现有数据库一同工作不会出现任何障碍。 + +### 从网页抓取数据:Beautiful Soup + +[Beautiful Soup][3](一般写作 BS4)库使得从 HTML 网页中提取信息变得非常简单。当我们需要把非结构化或弱结构化的 HTML 转换为结构化数据的时候,就需要使用 Beautiful Soup 。用它来处理 XML 数据也是一个很好的选择,否则 XML 的可读性或许会很差。 + +### 和 HTTP 内容打交道:Requests + +当需要和 HTTP 内容打交道的时候,[Requests][4] 毫无疑问是最好的标准库。当我们想要抓取 HTML 网页或连接 API 的时候,都离不开 Requests 库。同时,它也有很好的文档。 + +### 编写命令行工具:Click + +当需要写一个简单的 Python 脚本作为命令行工具的时候,[Click][5] 是我最喜欢用的库。它的 API 非常直观,并且在实现时经过了深思熟虑,我们只需要记住很少的几个模式。它的文档也很优秀,这使得学习其高级特性更加容易。 + +### 对事物命名:Python Slugify + +众所周知,命名是一件困难的事情。[Python Slugify][6] 是一个非常有用的库,它可以把一个标题或描述转成一个带有特性的唯一标识符。如果你正在做一个 Web 项目,并且你想要使用对搜索引擎优化友好SEO-friendly的链接,那么,使用 Python Slugify 可以让这件事变得很容易。 + +### 和插件打交道:Pluggy + +[Pluggy][7] 库相对较新,但是如果你想添加一个插件系统到现有应用中,那么使用 Pluggy 是最好也是最简单的方式。如果你使用过 pytest,那么实际上相当于已经使用过 Pluggy 了,虽然你还不知道它。 + +### 把 CSV 文件转换到 API 中:DataSette + +[DataSette][8] 是一个神奇的工具,它可以很容易地把 CSV 文件转换进全特性只读 REST JSON API,同时,不要把它和 Dataset 库混淆。Datasette 有许多特性,包括创建图表和 geo(用于创建交互式图表),并且很容易通过容器或第三方网络主机进行部署。 + +### 处理环境变量等:Envparse + +如果你不想在源代码中保存 API 密钥、数据库凭证或其他敏感信息,那么你便需要解析环境变量,这时候 [envparse][9] 是最好的选择。Envparse 能够处理环境变量、ENV 文件、变量类型,甚至还可以进行预处理和后处理(例如,你想要确保变量名总是大写或小写的) + +有什么你最喜欢的用于业余项目side projects的 Python 库不在这个列表中吗?请在评论中和我们分享。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/9/python-libraries-side-projects + +作者:[Jeff Triplett][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[ucasFL](https://github.com/ucasFL) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/laceynwilliams +[1]: https://dataset.readthedocs.io/en/latest/ +[2]: https://docs.djangoproject.com/en/2.1/ref/django-admin/#django-admin-inspectdb +[3]: https://www.crummy.com/software/BeautifulSoup/ +[4]: http://docs.python-requests.org/ +[5]: http://click.pocoo.org/5/ +[6]: https://github.com/un33k/python-slugify +[7]: https://pluggy.readthedocs.io/en/latest/ +[8]: https://github.com/simonw/datasette +[9]: https://github.com/rconradharris/envparse