mirror of https://github.com/ARMmbed/mbed-os.git
Python2+3: Use absolute import where possible
parent
4322bee175
commit
c93a2bfa4c
|
@ -1,3 +1,4 @@
|
|||
from __future__ import print_function, division, absolute_import
|
||||
import argparse
|
||||
from os.path import basename
|
||||
from tools.arm_pack_manager import Cache
|
||||
|
@ -5,7 +6,7 @@ from os.path import basename, join, dirname, exists
|
|||
from os import makedirs
|
||||
from itertools import takewhile
|
||||
from fuzzywuzzy import process
|
||||
from tools.arm_pack_manager import Cache
|
||||
from .arm_pack_manager import Cache
|
||||
|
||||
parser = argparse.ArgumentParser(description='A Handy little utility for keeping your cache of pack files up to date.')
|
||||
subparsers = parser.add_subparsers(title="Commands")
|
||||
|
@ -133,12 +134,12 @@ def command_find_part (cache, matches, long=False, intersection=True,
|
|||
aliases = sum([fuzzy_find([m], cache.aliases.keys()) for m in matches], [])
|
||||
if print_parts:
|
||||
for part in choices :
|
||||
print part
|
||||
print(part)
|
||||
if long :
|
||||
pp.pprint(cache.index[part])
|
||||
if print_aliases:
|
||||
for alias in aliases :
|
||||
print alias
|
||||
print(alias)
|
||||
if long :
|
||||
pp.pprint(cache.index[cache.aliases[alias]])
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
"""
|
||||
from __future__ import print_function
|
||||
from __future__ import print_function, division, absolute_import
|
||||
|
||||
import re
|
||||
import tempfile
|
||||
|
@ -27,20 +27,22 @@ from os import linesep, remove, makedirs
|
|||
from time import time
|
||||
from intelhex import IntelHex
|
||||
from json import load, dump
|
||||
from tools.arm_pack_manager import Cache
|
||||
|
||||
from tools.utils import mkdir, run_cmd, run_cmd_ext, NotSupportedException,\
|
||||
ToolException, InvalidReleaseTargetException, intelhex_offset
|
||||
from tools.paths import MBED_CMSIS_PATH, MBED_TARGETS_PATH, MBED_LIBRARIES,\
|
||||
MBED_HEADER, MBED_DRIVERS, MBED_PLATFORM, MBED_HAL, MBED_CONFIG_FILE,\
|
||||
MBED_LIBRARIES_DRIVERS, MBED_LIBRARIES_PLATFORM, MBED_LIBRARIES_HAL,\
|
||||
BUILD_DIR
|
||||
from tools.targets import TARGET_NAMES, TARGET_MAP
|
||||
from tools.libraries import Library
|
||||
from tools.toolchains import TOOLCHAIN_CLASSES
|
||||
from jinja2 import FileSystemLoader
|
||||
from jinja2.environment import Environment
|
||||
from tools.config import Config
|
||||
|
||||
from .arm_pack_manager import Cache
|
||||
from .utils import (mkdir, run_cmd, run_cmd_ext, NotSupportedException,
|
||||
ToolException, InvalidReleaseTargetException,
|
||||
intelhex_offset)
|
||||
from .paths import (MBED_CMSIS_PATH, MBED_TARGETS_PATH, MBED_LIBRARIES,
|
||||
MBED_HEADER, MBED_DRIVERS, MBED_PLATFORM, MBED_HAL,
|
||||
MBED_CONFIG_FILE, MBED_LIBRARIES_DRIVERS,
|
||||
MBED_LIBRARIES_PLATFORM, MBED_LIBRARIES_HAL,
|
||||
BUILD_DIR)
|
||||
from .targets import TARGET_NAMES, TARGET_MAP
|
||||
from .libraries import Library
|
||||
from .toolchains import TOOLCHAIN_CLASSES
|
||||
from .config import Config
|
||||
|
||||
RELEASE_VERSIONS = ['2', '5']
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
"""
|
||||
from __future__ import print_function, division, absolute_import
|
||||
|
||||
from copy import deepcopy
|
||||
from six import moves
|
||||
|
@ -28,11 +29,11 @@ from intelhex import IntelHex
|
|||
from jinja2 import FileSystemLoader, StrictUndefined
|
||||
from jinja2.environment import Environment
|
||||
from jsonschema import Draft4Validator, RefResolver
|
||||
# Implementation of mbed configuration mechanism
|
||||
from tools.utils import json_file_to_dict, intelhex_offset
|
||||
from tools.arm_pack_manager import Cache
|
||||
from tools.targets import CUMULATIVE_ATTRIBUTES, TARGET_MAP, \
|
||||
generate_py_target, get_resolution_order, Target
|
||||
|
||||
from ..utils import json_file_to_dict, intelhex_offset
|
||||
from ..arm_pack_manager import Cache
|
||||
from ..targets import (CUMULATIVE_ATTRIBUTES, TARGET_MAP, generate_py_target,
|
||||
get_resolution_order, Target)
|
||||
|
||||
try:
|
||||
unicode
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from __future__ import print_function, division, absolute_import
|
||||
|
||||
import sys
|
||||
from os.path import join, abspath, dirname, exists
|
||||
from os.path import basename, relpath, normpath, splitext
|
||||
|
@ -22,50 +24,43 @@ from os import makedirs, walk
|
|||
import copy
|
||||
from shutil import rmtree, copyfile
|
||||
import zipfile
|
||||
ROOT = abspath(join(dirname(__file__), ".."))
|
||||
sys.path.insert(0, ROOT)
|
||||
|
||||
from tools.build_api import prepare_toolchain
|
||||
from tools.build_api import scan_resources
|
||||
from tools.toolchains import Resources
|
||||
from tools.export import lpcxpresso, ds5_5, iar, makefile
|
||||
from tools.export import embitz, coide, kds, simplicity, atmelstudio, mcuxpresso
|
||||
from tools.export import sw4stm32, e2studio, zip, cmsis, uvision, cdt, vscode
|
||||
from tools.export import gnuarmeclipse
|
||||
from tools.export import qtcreator
|
||||
from tools.export import cmake
|
||||
from tools.export import nb
|
||||
from tools.targets import TARGET_NAMES
|
||||
from ..build_api import prepare_toolchain, scan_resources
|
||||
from ..toolchains import Resources
|
||||
from ..targets import TARGET_NAMES
|
||||
from . import (lpcxpresso, ds5_5, iar, makefile, embitz, coide, kds, simplicity,
|
||||
atmelstudio, mcuxpresso, sw4stm32, e2studio, zip, cmsis, uvision,
|
||||
cdt, vscode, gnuarmeclipse, qtcreator, cmake, nb)
|
||||
|
||||
EXPORTERS = {
|
||||
'uvision5': uvision.Uvision,
|
||||
'uvision': uvision.Uvision,
|
||||
'lpcxpresso': lpcxpresso.LPCXpresso,
|
||||
'gcc_arm': makefile.GccArm,
|
||||
'make_gcc_arm': makefile.GccArm,
|
||||
'make_armc5': makefile.Armc5,
|
||||
'make_armc6': makefile.Armc6,
|
||||
'make_iar': makefile.IAR,
|
||||
'ds5_5': ds5_5.DS5_5,
|
||||
'iar': iar.IAR,
|
||||
'embitz' : embitz.EmBitz,
|
||||
'coide' : coide.CoIDE,
|
||||
'kds' : kds.KDS,
|
||||
'simplicityv3' : simplicity.SimplicityV3,
|
||||
'atmelstudio' : atmelstudio.AtmelStudio,
|
||||
'sw4stm32' : sw4stm32.Sw4STM32,
|
||||
'e2studio' : e2studio.E2Studio,
|
||||
'eclipse_gcc_arm' : cdt.EclipseGcc,
|
||||
'eclipse_iar' : cdt.EclipseIAR,
|
||||
'eclipse_armc5' : cdt.EclipseArmc5,
|
||||
'gnuarmeclipse': gnuarmeclipse.GNUARMEclipse,
|
||||
'netbeans': nb.GNUARMNetbeans,
|
||||
'mcuxpresso': mcuxpresso.MCUXpresso,
|
||||
'qtcreator': qtcreator.QtCreator,
|
||||
'vscode_gcc_arm' : vscode.VSCodeGcc,
|
||||
'vscode_iar' : vscode.VSCodeIAR,
|
||||
'vscode_armc5' : vscode.VSCodeArmc5,
|
||||
'cmake_gcc_arm': cmake.GccArm
|
||||
u'uvision5': uvision.Uvision,
|
||||
u'uvision': uvision.Uvision,
|
||||
u'lpcxpresso': lpcxpresso.LPCXpresso,
|
||||
u'gcc_arm': makefile.GccArm,
|
||||
u'make_gcc_arm': makefile.GccArm,
|
||||
u'make_armc5': makefile.Armc5,
|
||||
u'make_armc6': makefile.Armc6,
|
||||
u'make_iar': makefile.IAR,
|
||||
u'ds5_5': ds5_5.DS5_5,
|
||||
u'iar': iar.IAR,
|
||||
u'embitz' : embitz.EmBitz,
|
||||
u'coide' : coide.CoIDE,
|
||||
u'kds' : kds.KDS,
|
||||
u'simplicityv3' : simplicity.SimplicityV3,
|
||||
u'atmelstudio' : atmelstudio.AtmelStudio,
|
||||
u'sw4stm32' : sw4stm32.Sw4STM32,
|
||||
u'e2studio' : e2studio.E2Studio,
|
||||
u'eclipse_gcc_arm' : cdt.EclipseGcc,
|
||||
u'eclipse_iar' : cdt.EclipseIAR,
|
||||
u'eclipse_armc5' : cdt.EclipseArmc5,
|
||||
u'gnuarmeclipse': gnuarmeclipse.GNUARMEclipse,
|
||||
u'mcuxpresso': mcuxpresso.MCUXpresso,
|
||||
u'netbeans': nb.GNUARMNetbeans,
|
||||
u'qtcreator': qtcreator.QtCreator,
|
||||
u'vscode_gcc_arm' : vscode.VSCodeGcc,
|
||||
u'vscode_iar' : vscode.VSCodeIAR,
|
||||
u'vscode_armc5' : vscode.VSCodeArmc5,
|
||||
u'cmake_gcc_arm': cmake.GccArm
|
||||
}
|
||||
|
||||
ERROR_MESSAGE_UNSUPPORTED_TOOLCHAIN = """
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
"""Memory Map File Analyser for ARM mbed"""
|
||||
from __future__ import print_function
|
||||
from __future__ import print_function, division, absolute_import
|
||||
|
||||
from abc import abstractmethod, ABCMeta
|
||||
from sys import stdout, exit, argv
|
||||
|
@ -16,8 +16,8 @@ from copy import deepcopy
|
|||
from prettytable import PrettyTable
|
||||
from tools.arm_pack_manager import Cache
|
||||
|
||||
from tools.utils import argparse_filestring_type, \
|
||||
argparse_lowercase_hyphen_type, argparse_uppercase_type
|
||||
from .utils import (argparse_filestring_type, argparse_lowercase_hyphen_type,
|
||||
argparse_uppercase_type)
|
||||
|
||||
|
||||
class _Parser(object):
|
||||
|
|
|
@ -14,16 +14,19 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
"""
|
||||
from __future__ import print_function, division, absolute_import
|
||||
|
||||
from json import load
|
||||
from os.path import join, dirname
|
||||
from os import listdir
|
||||
from argparse import ArgumentParser, ArgumentTypeError
|
||||
from tools.toolchains import TOOLCHAINS
|
||||
from tools.targets import TARGET_NAMES, Target, update_target_data
|
||||
from tools.utils import argparse_force_uppercase_type, \
|
||||
argparse_lowercase_hyphen_type, argparse_many, \
|
||||
argparse_filestring_type, args_error, argparse_profile_filestring_type,\
|
||||
argparse_deprecate
|
||||
|
||||
from .toolchains import TOOLCHAINS
|
||||
from .targets import TARGET_NAMES, Target, update_target_data
|
||||
from .utils import (argparse_force_uppercase_type, argparse_deprecate,
|
||||
argparse_lowercase_hyphen_type, argparse_many,
|
||||
argparse_filestring_type, args_error,
|
||||
argparse_profile_filestring_type)
|
||||
|
||||
FLAGS_DEPRECATION_MESSAGE = "Please use the --profile argument instead.\n"\
|
||||
"Documentation may be found in "\
|
||||
|
|
|
@ -14,7 +14,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
"""
|
||||
from __future__ import print_function
|
||||
from __future__ import print_function, division, absolute_import
|
||||
|
||||
import re
|
||||
import sys
|
||||
|
@ -22,21 +22,23 @@ from os import stat, walk, getcwd, sep, remove
|
|||
from copy import copy
|
||||
from time import time, sleep
|
||||
from shutil import copyfile
|
||||
from os.path import join, splitext, exists, relpath, dirname, basename, split, abspath, isfile, isdir, normcase
|
||||
from os.path import (join, splitext, exists, relpath, dirname, basename, split,
|
||||
abspath, isfile, isdir, normcase)
|
||||
from itertools import chain
|
||||
from inspect import getmro
|
||||
from copy import deepcopy
|
||||
from abc import ABCMeta, abstractmethod
|
||||
from distutils.spawn import find_executable
|
||||
|
||||
from multiprocessing import Pool, cpu_count
|
||||
from tools.utils import run_cmd, mkdir, rel_path, ToolException, NotSupportedException, split_path, compile_worker
|
||||
from tools.settings import MBED_ORG_USER
|
||||
import tools.hooks as hooks
|
||||
from tools.memap import MemapParser
|
||||
from hashlib import md5
|
||||
import fnmatch
|
||||
|
||||
from ..utils import (run_cmd, mkdir, rel_path, ToolException,
|
||||
NotSupportedException, split_path, compile_worker)
|
||||
from ..settings import MBED_ORG_USER
|
||||
from .. import hooks
|
||||
from ..memap import MemapParser
|
||||
|
||||
|
||||
#Disables multiprocessing if set to higher number than the host machine CPUs
|
||||
CPU_COUNT_MIN = 1
|
||||
|
|
|
@ -14,7 +14,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
"""
|
||||
from __future__ import print_function
|
||||
from __future__ import print_function, division, absolute_import
|
||||
import sys
|
||||
import inspect
|
||||
import os
|
||||
|
@ -417,11 +417,8 @@ def argparse_force_type(case):
|
|||
if not isinstance(string, unicode):
|
||||
string = string.decode()
|
||||
for option in lst:
|
||||
try:
|
||||
if case(string) == case(option):
|
||||
return option
|
||||
except Exception as e:
|
||||
print(e)
|
||||
if case(string) == case(option):
|
||||
return option
|
||||
raise argparse.ArgumentTypeError(
|
||||
"{0} is not a supported {1}. Supported {1}s are:\n{2}".
|
||||
format(string, type_name, columnate(lst)))
|
||||
|
|
Loading…
Reference in New Issue