Use native open/io.open for file contents reading/writing

This commit is contained in:
Ivan Kravets
2020-03-05 23:52:13 +02:00
parent 3275bb59bf
commit ce6b96ea84
10 changed files with 56 additions and 39 deletions

View File

@@ -187,9 +187,9 @@ def init_base_project(project_dir):
def init_include_readme(include_dir):
fs.write_file_contents(
os.path.join(include_dir, "README"),
"""
with open(os.path.join(include_dir, "README"), "w") as fp:
fp.write(
"""
This directory is intended for project header files.
A header file is a file containing C declarations and macro definitions
@@ -229,14 +229,14 @@ Read more about using header files in official GCC documentation:
https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html
""",
)
)
def init_lib_readme(lib_dir):
# pylint: disable=line-too-long
fs.write_file_contents(
os.path.join(lib_dir, "README"),
"""
with open(os.path.join(lib_dir, "README"), "w") as fp:
fp.write(
"""
This directory is intended for project specific (private) libraries.
PlatformIO will compile them to static libraries and link into executable file.
@@ -283,13 +283,13 @@ libraries scanning project source files.
More information about PlatformIO Library Dependency Finder
- https://docs.platformio.org/page/librarymanager/ldf.html
""",
)
)
def init_test_readme(test_dir):
fs.write_file_contents(
os.path.join(test_dir, "README"),
"""
with open(os.path.join(test_dir, "README"), "w") as fp:
fp.write(
"""
This directory is intended for PIO Unit Testing and project tests.
Unit Testing is a software testing method by which individual units of
@@ -301,16 +301,16 @@ in the development cycle.
More information about PIO Unit Testing:
- https://docs.platformio.org/page/plus/unit-testing.html
""",
)
)
def init_ci_conf(project_dir):
conf_path = os.path.join(project_dir, ".travis.yml")
if os.path.isfile(conf_path):
return
fs.write_file_contents(
conf_path,
"""# Continuous Integration (CI) is the practice, in software
with open(conf_path, "w") as fp:
fp.write(
"""# Continuous Integration (CI) is the practice, in software
# engineering, of merging all developer working copies with a shared mainline
# several times a day < https://docs.platformio.org/page/ci/index.html >
#
@@ -378,14 +378,15 @@ def init_ci_conf(project_dir):
# script:
# - platformio ci --lib="." --board=ID_1 --board=ID_2 --board=ID_N
""",
)
)
def init_cvs_ignore(project_dir):
conf_path = os.path.join(project_dir, ".gitignore")
if os.path.isfile(conf_path):
return
fs.write_file_contents(conf_path, ".pio\n")
with open(conf_path, "w") as fp:
fp.write(".pio\n")
def fill_project_envs(