2009-04-26 03:56:41 +04:00
|
|
|
# config.py - configuration parsing for Mercurial
|
|
|
|
#
|
|
|
|
# Copyright 2009 Matt Mackall <mpm@selenic.com> and others
|
|
|
|
#
|
|
|
|
# This software may be used and distributed according to the terms of the
|
2010-01-20 07:20:08 +03:00
|
|
|
# GNU General Public License version 2 or any later version.
|
2009-04-26 03:56:41 +04:00
|
|
|
|
2015-08-08 10:28:53 +03:00
|
|
|
from __future__ import absolute_import
|
|
|
|
|
|
|
|
import os
|
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
from . import error, pycompat, util
|
|
|
|
|
2009-04-24 00:40:10 +04:00
|
|
|
|
2009-04-27 01:50:43 +04:00
|
|
|
class config(object):
|
2017-03-12 22:56:12 +03:00
|
|
|
def __init__(self, data=None, includepaths=None):
|
2009-04-24 00:40:10 +04:00
|
|
|
self._data = {}
|
2013-04-26 18:36:12 +04:00
|
|
|
self._unset = []
|
2017-03-12 22:56:12 +03:00
|
|
|
self._includepaths = includepaths or []
|
2009-04-24 00:40:10 +04:00
|
|
|
if data:
|
|
|
|
for k in data._data:
|
|
|
|
self._data[k] = data[k].copy()
|
2009-04-27 01:50:43 +04:00
|
|
|
self._source = data._source.copy()
|
2017-09-28 04:07:48 +03:00
|
|
|
else:
|
|
|
|
self._source = util.cowdict()
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2009-04-24 00:40:10 +04:00
|
|
|
def copy(self):
|
|
|
|
return config(self)
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2009-04-24 00:40:10 +04:00
|
|
|
def __contains__(self, section):
|
|
|
|
return section in self._data
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2016-01-08 06:45:03 +03:00
|
|
|
def hasitem(self, section, item):
|
|
|
|
return item in self._data.get(section, {})
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2009-04-27 01:50:43 +04:00
|
|
|
def __getitem__(self, section):
|
|
|
|
return self._data.get(section, {})
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2009-04-27 01:50:43 +04:00
|
|
|
def __iter__(self):
|
|
|
|
for d in self.sections():
|
|
|
|
yield d
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2009-04-27 01:50:43 +04:00
|
|
|
def update(self, src):
|
2017-09-28 04:07:48 +03:00
|
|
|
self._source = self._source.preparewrite()
|
2013-04-26 18:36:12 +04:00
|
|
|
for s, n in src._unset:
|
2017-09-28 04:07:48 +03:00
|
|
|
ds = self._data.get(s, None)
|
|
|
|
if ds is not None and n in ds:
|
|
|
|
self._data[s] = ds.preparewrite()
|
2013-04-26 18:36:12 +04:00
|
|
|
del self._data[s][n]
|
|
|
|
del self._source[(s, n)]
|
2009-04-27 01:50:43 +04:00
|
|
|
for s in src:
|
2017-09-28 04:07:48 +03:00
|
|
|
ds = self._data.get(s, None)
|
|
|
|
if ds:
|
|
|
|
self._data[s] = ds.preparewrite()
|
|
|
|
else:
|
|
|
|
self._data[s] = util.cowsortdict()
|
2009-04-27 01:50:43 +04:00
|
|
|
self._data[s].update(src._data[s])
|
|
|
|
self._source.update(src._source)
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2009-04-24 00:40:10 +04:00
|
|
|
def get(self, section, item, default=None):
|
2009-04-27 01:50:43 +04:00
|
|
|
return self._data.get(section, {}).get(item, default)
|
2012-01-18 19:52:26 +04:00
|
|
|
|
|
|
|
def backup(self, section, item):
|
2012-08-18 00:58:19 +04:00
|
|
|
"""return a tuple allowing restore to reinstall a previous value
|
2012-01-18 19:52:26 +04:00
|
|
|
|
2012-08-18 00:58:19 +04:00
|
|
|
The main reason we need it is because it handles the "no data" case.
|
2012-01-18 19:52:26 +04:00
|
|
|
"""
|
|
|
|
try:
|
|
|
|
value = self._data[section][item]
|
|
|
|
source = self.source(section, item)
|
|
|
|
return (section, item, value, source)
|
|
|
|
except KeyError:
|
|
|
|
return (section, item)
|
|
|
|
|
2009-04-27 01:50:43 +04:00
|
|
|
def source(self, section, item):
|
2009-04-27 01:50:43 +04:00
|
|
|
return self._source.get((section, item), "")
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2009-04-24 00:40:10 +04:00
|
|
|
def sections(self):
|
|
|
|
return sorted(self._data.keys())
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2009-04-24 00:40:10 +04:00
|
|
|
def items(self, section):
|
2017-05-18 23:38:37 +03:00
|
|
|
return list(self._data.get(section, {}).iteritems())
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2009-04-24 00:40:10 +04:00
|
|
|
def set(self, section, item, value, source=""):
|
2017-03-03 22:42:56 +03:00
|
|
|
if pycompat.ispy3:
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
assert not isinstance(
|
|
|
|
value, str
|
|
|
|
), "config values may not be unicode strings on Python 3"
|
2009-04-24 00:40:10 +04:00
|
|
|
if section not in self:
|
2017-09-28 04:07:48 +03:00
|
|
|
self._data[section] = util.cowsortdict()
|
|
|
|
else:
|
|
|
|
self._data[section] = self._data[section].preparewrite()
|
2009-04-27 01:50:43 +04:00
|
|
|
self._data[section][item] = value
|
2014-03-19 05:45:14 +04:00
|
|
|
if source:
|
2017-09-28 04:07:48 +03:00
|
|
|
self._source = self._source.preparewrite()
|
2014-03-19 05:45:14 +04:00
|
|
|
self._source[(section, item)] = source
|
2009-04-24 00:40:10 +04:00
|
|
|
|
2012-01-18 19:52:26 +04:00
|
|
|
def restore(self, data):
|
|
|
|
"""restore data returned by self.backup"""
|
2017-09-28 04:07:48 +03:00
|
|
|
self._source = self._source.preparewrite()
|
2012-01-18 19:52:26 +04:00
|
|
|
if len(data) == 4:
|
|
|
|
# restore old data
|
|
|
|
section, item, value, source = data
|
2017-09-28 04:07:48 +03:00
|
|
|
self._data[section] = self._data[section].preparewrite()
|
2012-01-18 19:52:26 +04:00
|
|
|
self._data[section][item] = value
|
|
|
|
self._source[(section, item)] = source
|
|
|
|
else:
|
|
|
|
# no data before, remove everything
|
|
|
|
section, item = data
|
|
|
|
if section in self._data:
|
2014-08-06 08:16:24 +04:00
|
|
|
self._data[section].pop(item, None)
|
2012-01-18 19:52:26 +04:00
|
|
|
self._source.pop((section, item), None)
|
|
|
|
|
2009-05-01 04:22:06 +04:00
|
|
|
def parse(self, src, data, sections=None, remap=None, include=None):
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
sectionre = util.re.compile(br"\[([^\[]+)\]")
|
|
|
|
itemre = util.re.compile(br"([^=\s][^=]*?)\s*=\s*(.*\S|)")
|
|
|
|
contre = util.re.compile(br"\s+(\S|\S.*\S)\s*$")
|
|
|
|
emptyre = util.re.compile(br"(;|#|\s*$)")
|
|
|
|
commentre = util.re.compile(br"(;|#)")
|
|
|
|
unsetre = util.re.compile(br"%unset\s+(\S+)")
|
|
|
|
includere = util.re.compile(br"%include\s+(\S|\S.*\S)\s*$")
|
2009-04-24 00:40:10 +04:00
|
|
|
section = ""
|
|
|
|
item = None
|
|
|
|
line = 0
|
2009-08-12 13:50:27 +04:00
|
|
|
cont = False
|
2009-04-27 01:50:43 +04:00
|
|
|
|
2017-10-14 11:41:41 +03:00
|
|
|
if remap:
|
|
|
|
section = remap.get(section, section)
|
|
|
|
|
2009-07-13 04:50:26 +04:00
|
|
|
for l in data.splitlines(True):
|
2009-04-24 00:40:10 +04:00
|
|
|
line += 1
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
if line == 1 and l.startswith("\xef\xbb\xbf"):
|
2012-04-03 20:35:04 +04:00
|
|
|
# Someone set us up the BOM
|
|
|
|
l = l[3:]
|
2009-04-24 00:40:10 +04:00
|
|
|
if cont:
|
2011-06-16 22:24:44 +04:00
|
|
|
if commentre.match(l):
|
|
|
|
continue
|
2009-04-24 00:40:10 +04:00
|
|
|
m = contre.match(l)
|
|
|
|
if m:
|
2009-04-27 01:50:43 +04:00
|
|
|
if sections and section not in sections:
|
|
|
|
continue
|
2009-04-24 00:40:10 +04:00
|
|
|
v = self.get(section, item) + "\n" + m.group(1)
|
2009-05-01 04:22:06 +04:00
|
|
|
self.set(section, item, v, "%s:%d" % (src, line))
|
2009-04-24 00:40:10 +04:00
|
|
|
continue
|
|
|
|
item = None
|
2009-09-12 13:17:07 +04:00
|
|
|
cont = False
|
2009-04-27 01:50:43 +04:00
|
|
|
m = includere.match(l)
|
2015-05-15 16:04:32 +03:00
|
|
|
|
|
|
|
if m and include:
|
|
|
|
expanded = util.expandpath(m.group(1))
|
|
|
|
includepaths = [os.path.dirname(src)] + self._includepaths
|
|
|
|
|
|
|
|
for base in includepaths:
|
|
|
|
inc = os.path.normpath(os.path.join(base, expanded))
|
|
|
|
|
2009-12-12 18:46:16 +03:00
|
|
|
try:
|
|
|
|
include(inc, remap=remap, sections=sections)
|
2015-05-15 16:04:32 +03:00
|
|
|
break
|
2018-02-22 14:17:58 +03:00
|
|
|
except IOError:
|
|
|
|
pass
|
2009-04-27 01:50:43 +04:00
|
|
|
continue
|
2009-04-24 00:40:10 +04:00
|
|
|
if emptyre.match(l):
|
|
|
|
continue
|
|
|
|
m = sectionre.match(l)
|
|
|
|
if m:
|
|
|
|
section = m.group(1)
|
2009-05-04 23:21:43 +04:00
|
|
|
if remap:
|
|
|
|
section = remap.get(section, section)
|
2009-04-24 00:40:10 +04:00
|
|
|
if section not in self:
|
2017-09-28 04:07:48 +03:00
|
|
|
self._data[section] = util.cowsortdict()
|
2009-04-24 00:40:10 +04:00
|
|
|
continue
|
|
|
|
m = itemre.match(l)
|
|
|
|
if m:
|
|
|
|
item = m.group(1)
|
2009-08-12 13:50:27 +04:00
|
|
|
cont = True
|
2009-04-27 01:50:43 +04:00
|
|
|
if sections and section not in sections:
|
|
|
|
continue
|
2009-05-01 04:22:06 +04:00
|
|
|
self.set(section, item, m.group(2), "%s:%d" % (src, line))
|
2009-04-24 00:40:10 +04:00
|
|
|
continue
|
2009-04-27 01:50:43 +04:00
|
|
|
m = unsetre.match(l)
|
|
|
|
if m:
|
|
|
|
name = m.group(1)
|
2009-04-27 01:50:43 +04:00
|
|
|
if sections and section not in sections:
|
|
|
|
continue
|
2010-11-22 20:15:58 +03:00
|
|
|
if self.get(section, name) is not None:
|
2017-10-03 22:00:07 +03:00
|
|
|
self._data[section] = self._data[section].preparewrite()
|
2009-04-27 01:50:43 +04:00
|
|
|
del self._data[section][name]
|
2013-04-26 18:36:12 +04:00
|
|
|
self._unset.append((section, name))
|
2009-04-27 01:50:43 +04:00
|
|
|
continue
|
|
|
|
|
2010-06-05 05:57:26 +04:00
|
|
|
raise error.ParseError(l.rstrip(), ("%s:%s" % (src, line)))
|
2009-05-01 04:22:06 +04:00
|
|
|
|
|
|
|
def read(self, path, fp=None, sections=None, remap=None):
|
|
|
|
if not fp:
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
fp = util.posixfile(path, "rb")
|
|
|
|
assert getattr(fp, "mode", r"rb") == r"rb", (
|
|
|
|
"config files must be opened in binary mode, got fp=%r mode=%r"
|
|
|
|
% (fp, fp.mode)
|
|
|
|
)
|
|
|
|
self.parse(path, fp.read(), sections=sections, remap=remap, include=self.read)
|
|
|
|
|
2017-03-17 19:19:56 +03:00
|
|
|
|
|
|
|
def parselist(value):
|
|
|
|
"""parse a configuration value as a list of comma/space separated strings
|
|
|
|
|
2017-09-03 08:32:11 +03:00
|
|
|
>>> parselist(b'this,is "a small" ,test')
|
2017-03-17 19:19:56 +03:00
|
|
|
['this', 'is', 'a small', 'test']
|
|
|
|
"""
|
|
|
|
|
|
|
|
def _parse_plain(parts, s, offset):
|
|
|
|
whitespace = False
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
while offset < len(s) and (
|
|
|
|
s[offset : offset + 1].isspace() or s[offset : offset + 1] == ","
|
|
|
|
):
|
2017-03-17 19:19:56 +03:00
|
|
|
whitespace = True
|
|
|
|
offset += 1
|
|
|
|
if offset >= len(s):
|
|
|
|
return None, parts, offset
|
|
|
|
if whitespace:
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
parts.append("")
|
|
|
|
if s[offset : offset + 1] == '"' and not parts[-1]:
|
2017-03-17 19:19:56 +03:00
|
|
|
return _parse_quote, parts, offset + 1
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
elif s[offset : offset + 1] == '"' and parts[-1][-1] == "\\":
|
|
|
|
parts[-1] = parts[-1][:-1] + s[offset : offset + 1]
|
2017-03-17 19:19:56 +03:00
|
|
|
return _parse_plain, parts, offset + 1
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
parts[-1] += s[offset : offset + 1]
|
2017-03-17 19:19:56 +03:00
|
|
|
return _parse_plain, parts, offset + 1
|
|
|
|
|
|
|
|
def _parse_quote(parts, s, offset):
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
if offset < len(s) and s[offset : offset + 1] == '"': # ""
|
|
|
|
parts.append("")
|
2017-03-17 19:19:56 +03:00
|
|
|
offset += 1
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
while offset < len(s) and (
|
|
|
|
s[offset : offset + 1].isspace() or s[offset : offset + 1] == ","
|
|
|
|
):
|
2017-03-17 19:19:56 +03:00
|
|
|
offset += 1
|
|
|
|
return _parse_plain, parts, offset
|
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
while offset < len(s) and s[offset : offset + 1] != '"':
|
|
|
|
if (
|
|
|
|
s[offset : offset + 1] == "\\"
|
|
|
|
and offset + 1 < len(s)
|
|
|
|
and s[offset + 1 : offset + 2] == '"'
|
|
|
|
):
|
2017-03-17 19:19:56 +03:00
|
|
|
offset += 1
|
|
|
|
parts[-1] += '"'
|
|
|
|
else:
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
parts[-1] += s[offset : offset + 1]
|
2017-03-17 19:19:56 +03:00
|
|
|
offset += 1
|
|
|
|
|
|
|
|
if offset >= len(s):
|
|
|
|
real_parts = _configlist(parts[-1])
|
|
|
|
if not real_parts:
|
|
|
|
parts[-1] = '"'
|
|
|
|
else:
|
|
|
|
real_parts[0] = '"' + real_parts[0]
|
|
|
|
parts = parts[:-1]
|
|
|
|
parts.extend(real_parts)
|
|
|
|
return None, parts, offset
|
|
|
|
|
|
|
|
offset += 1
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
while offset < len(s) and s[offset : offset + 1] in [" ", ","]:
|
2017-03-17 19:19:56 +03:00
|
|
|
offset += 1
|
|
|
|
|
|
|
|
if offset < len(s):
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
if offset + 1 == len(s) and s[offset : offset + 1] == '"':
|
2017-03-17 19:19:56 +03:00
|
|
|
parts[-1] += '"'
|
|
|
|
offset += 1
|
|
|
|
else:
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
parts.append("")
|
2017-03-17 19:19:56 +03:00
|
|
|
else:
|
|
|
|
return None, parts, offset
|
|
|
|
|
|
|
|
return _parse_plain, parts, offset
|
|
|
|
|
|
|
|
def _configlist(s):
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
s = s.rstrip(" ,")
|
2017-03-17 19:19:56 +03:00
|
|
|
if not s:
|
|
|
|
return []
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
parser, parts, offset = _parse_plain, [""], 0
|
2017-03-17 19:19:56 +03:00
|
|
|
while parser:
|
|
|
|
parser, parts, offset = parser(parts, s, offset)
|
|
|
|
return parts
|
|
|
|
|
|
|
|
if value is not None and isinstance(value, bytes):
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
result = _configlist(value.lstrip(" ,\n"))
|
2017-03-17 19:19:56 +03:00
|
|
|
else:
|
|
|
|
result = value
|
|
|
|
return result or []
|