Refactore code without "arrow" dependency (resolve issue with "ImportError: No module named backports.functools_lru_cache")

This commit is contained in:
Ivan Kravets
2018-01-16 00:06:24 +02:00
parent affd53eb27
commit 3289b36450
8 changed files with 25 additions and 33 deletions

View File

@ -1,3 +1,3 @@
[settings]
line_length=79
known_third_party=arrow,bottle,click,lockfile,pytest,requests,SCons,semantic_version,serial
known_third_party=bottle,click,lockfile,python-dateutil,pytest,requests,SCons,semantic_version,serial

View File

@ -14,6 +14,7 @@ PlatformIO 3.0
* Configure a custom firmware/program name in build directory (`example <http://docs.platformio.org/page/projectconf/advanced_scripting.html#custom-firmware-program-name>`__)
* Renamed ``envs_dir`` option to ``build_dir``
in `Project Configuration File "platformio.ini" <http://docs.platformio.org/page/projectconf/section_platformio.html#build-dir>`__
* Refactored code without "arrow" dependency (resolve issue with "ImportError: No module named backports.functools_lru_cache")
* Improved support of PIO Unified Debugger for Eclipse Oxygen
* Improved a work in off-line mode
* Fixed project generator for CLion IDE

2
docs

Submodule docs updated: 1d05a91d45...8ad4e900ea

View File

@ -291,9 +291,8 @@ class LibBuilderBase(object):
def get_search_files(self):
items = [
join(self.src_dir, item)
for item in self.env.MatchSourceFiles(self.src_dir,
self.src_filter)
join(self.src_dir, item) for item in self.env.MatchSourceFiles(
self.src_dir, self.src_filter)
]
include_dir = self.include_dir
if include_dir:
@ -644,9 +643,9 @@ class ProjectAsLibBuilder(LibBuilderBase):
# test files
if "__test" in COMMAND_LINE_TARGETS:
items.extend([
join("$PROJECTTEST_DIR", item)
for item in self.env.MatchSourceFiles("$PROJECTTEST_DIR",
"$PIOTEST_SRC_FILTER")
join("$PROJECTTEST_DIR",
item) for item in self.env.MatchSourceFiles(
"$PROJECTTEST_DIR", "$PIOTEST_SRC_FILTER")
])
return items

View File

@ -19,7 +19,6 @@ from os.path import isdir, join
from time import sleep
from urllib import quote
import arrow
import click
from platformio import exception, util
@ -323,9 +322,7 @@ def lib_show(library, json_output):
click.echo(lib['description'])
click.echo()
click.echo("Version: %s, released %s" %
(lib['version']['name'],
arrow.get(lib['version']['released']).humanize()))
click.echo("Version: {name}, released {released}".format(**lib['version']))
click.echo("Manifest: %s" % lib['confurl'])
for key in ("homepage", "repository", "license"):
if key not in lib or not lib[key]:
@ -360,11 +357,10 @@ def lib_show(library, json_output):
blocks.append(("Compatible %s" % key, [i['title'] for i in lib[key]]))
blocks.append(("Headers", lib['headers']))
blocks.append(("Examples", lib['examples']))
blocks.append(("Versions", [
"%s, released %s" % (v['name'], arrow.get(v['released']).humanize())
for v in lib['versions']
]))
blocks.append(("Unique Downloads", [
blocks.append(
("Versions",
["{name}, released {released}".format(**v) for v in lib['versions']]))
blocks.append(("Downloads", [
"Today: %s" % lib['dlstats']['day'],
"Week: %s" % lib['dlstats']['week'],
"Month: %s" % lib['dlstats']['month']
@ -423,9 +419,7 @@ def lib_stats(json_output):
click.echo((printitemdate_tpl
if "date" in item else printitem_tpl).format(
name=click.style(item['name'], fg="cyan"),
date=str(
arrow.get(item['date']).humanize()
if "date" in item else ""),
date=item.get("date"),
url=click.style(
"http://platformio.org/lib/show/%s/%s" %
(item['id'], quote(item['name'])),

View File

@ -20,8 +20,8 @@ import re
from glob import glob
from os.path import isdir, join
import arrow
import click
from dateutil.parser import parse as parse_date
from platformio import app, commands, exception, util
from platformio.managers.package import BasePkgManager
@ -157,8 +157,8 @@ class LibraryManager(BasePkgManager):
def max_satisfying_repo_version(self, versions, requirements=None):
def _cmp_dates(datestr1, datestr2):
date1 = arrow.get(datestr1)
date2 = arrow.get(datestr2)
date1 = parse_date(datestr1)
date2 = parse_date(datestr2)
if date1 == date2:
return 0
return -1 if date1 < date2 else 1

View File

@ -18,11 +18,11 @@ from platformio import (__author__, __description__, __email__, __license__,
__title__, __url__, __version__)
install_requires = [
"arrow>=0.10.0,!=0.11.0",
"bottle<0.13",
"click>=5,<6",
"colorama",
"lockfile>=0.9.1,<0.13",
"python-dateutil",
"pyserial>=3,<4,!=3.3",
"requests>=2.4.0,<3",
"semantic_version>=2.5.0,<3"

View File

@ -141,8 +141,7 @@ def test_global_lib_list(clirunner, validate_cliresult):
result = clirunner.invoke(cmd_lib, ["-g", "list"])
validate_cliresult(result)
assert all([
n in result.output
for n in
n in result.output for n in
("Source: https://github.com/adafruit/Adafruit-ST7735-Library/archive/master.zip",
"Version: 5.10.1",
"Source: git+https://github.com/gioblu/PJON.git#3.0",
@ -151,8 +150,7 @@ def test_global_lib_list(clirunner, validate_cliresult):
result = clirunner.invoke(cmd_lib, ["-g", "list", "--json-output"])
assert all([
n in result.output
for n in
n in result.output for n in
("__pkg_dir",
'"__src_url": "git+https://gitlab.com/ivankravets/rs485-nodeproto.git"',
'"version": "5.10.1"')
@ -172,10 +170,10 @@ def test_global_lib_list(clirunner, validate_cliresult):
for item in json.loads(result.output)
]
versions2 = [
'ArduinoJson@5c33fd4', 'ArduinoJson@5.8.2', 'ArduinoJson@5.10.1',
'AsyncMqttClient@0.8.2', 'AsyncTCP@1.0.1', 'ESPAsyncTCP@1.1.3',
'NeoPixelBus@2.2.4', 'PJON@07fe9aa', 'PJON@1fb26fd',
'PubSubClient@bef5814', 'RFcontrol@77d4eb3f8a', 'RadioHead-1.62@0.0.0'
'ArduinoJson@5.8.2', 'ArduinoJson@5.10.1', 'AsyncMqttClient@0.8.2',
'AsyncTCP@1.0.1', 'ESPAsyncTCP@1.1.3', 'NeoPixelBus@2.2.4',
'PJON@07fe9aa', 'PJON@1fb26fd', 'PubSubClient@bef5814',
'RFcontrol@77d4eb3f8a', 'RadioHead-1.62@0.0.0'
]
assert set(versions1) >= set(versions2)
@ -272,7 +270,7 @@ def test_lib_stats(clirunner, validate_cliresult):
validate_cliresult(result)
assert all([
s in result.output
for s in ("UPDATED", "ago", "http://platformio.org/lib/show")
for s in ("UPDATED", "POPULAR", "http://platformio.org/lib/show")
])
result = clirunner.invoke(cmd_lib, ["stats", "--json-output"])