Skip to content

Commit f040936

Browse files
committed
Revert "Remove yaml exporter"
This reverts commit 4f7804b.
1 parent a215fe4 commit f040936

File tree

1 file changed

+23
-8
lines changed

1 file changed

+23
-8
lines changed

tools/export/__init__.py

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import os, tempfile
1818
from os.path import join, exists, basename
1919
from shutil import copytree, rmtree, copy
20+
import yaml
2021

2122
from tools.utils import mkdir
2223
from tools.export import uvision4, codered, gccarm, ds5_5, iar, emblocks, coide, kds, zip, simplicityv3, atmelstudio, sw4stm32
@@ -54,7 +55,7 @@ def online_build_url_resolver(url):
5455

5556

5657
def export(project_path, project_name, ide, target, destination='/tmp/',
57-
tempdir=None, clean=True, extra_symbols=None, zip=True, build_url_resolver=online_build_url_resolver):
58+
tempdir=None, clean=True, extra_symbols=None, build_url_resolver=online_build_url_resolver):
5859
# Convention: we are using capitals for toolchain and target names
5960
if target is not None:
6061
target = target.upper()
@@ -108,16 +109,30 @@ def export(project_path, project_name, ide, target, destination='/tmp/',
108109

109110
zip_path = None
110111
if report['success']:
112+
# readme.txt to contain more exported data
113+
exporter_yaml = {
114+
'project_generator': {
115+
'active' : False,
116+
}
117+
}
118+
if use_progen:
119+
try:
120+
import pkg_resources
121+
version = pkg_resources.get_distribution('project_generator').version
122+
exporter_yaml['project_generator']['version'] = version
123+
exporter_yaml['project_generator']['active'] = True;
124+
exporter_yaml['project_generator_definitions'] = {}
125+
version = pkg_resources.get_distribution('project_generator_definitions').version
126+
exporter_yaml['project_generator_definitions']['version'] = version
127+
except ImportError:
128+
pass
129+
with open(os.path.join(tempdir, 'exporter.yaml'), 'w') as outfile:
130+
yaml.dump(exporter_yaml, outfile, default_flow_style=False)
111131
# add readme file to every offline export.
112132
open(os.path.join(tempdir, 'GettingStarted.htm'),'w').write('<meta http-equiv="refresh" content="0; url=http://mbed.org/handbook/Getting-Started-mbed-Exporters#%s"/>'% (ide))
113133
# copy .hgignore file to exported direcotry as well.
114-
if exists(os.path.join(exporter.TEMPLATE_DIR,'.hgignore')):
115-
copy(os.path.join(exporter.TEMPLATE_DIR,'.hgignore'),tempdir)
116-
117-
if zip:
118-
zip_path = zip_working_directory_and_clean_up(tempdir, destination, project_name, clean)
119-
else:
120-
zip_path = destination
134+
copy(os.path.join(exporter.TEMPLATE_DIR,'.hgignore'),tempdir)
135+
zip_path = zip_working_directory_and_clean_up(tempdir, destination, project_name, clean)
121136

122137
return zip_path, report
123138

0 commit comments

Comments
 (0)