Skip to content

exporters - group by directories in prj root #3559

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 12, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions tools/export/exporters.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import os
from abc import abstractmethod, ABCMeta
import logging
from os.path import join, dirname, relpath, basename, realpath
from os.path import join, dirname, relpath, basename, realpath, normpath
from itertools import groupby
from jinja2 import FileSystemLoader
from jinja2.environment import Environment
Expand Down Expand Up @@ -130,9 +130,13 @@ def make_key(self, src):
Positional Arguments:
src - the src's location
"""
key = basename(dirname(src))
if key == ".":
key = basename(realpath(self.export_dir))
rel_path = relpath(src, self.resources.file_basepath[src])
path_list = os.path.normpath(rel_path).split(os.sep)
assert path_list >= 1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the assert here? Wouldn't this trigger a runtime traceback if it were true?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additionally, what is the check trying to accomplish? It is not comparing the length of the list.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. This is a mistake and should be removed or updated to be "len(path_list )".

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @c1728p9. Probably the easiest way to fix this is to just submit another PR, changing this assert to an exception that actually checks len(path_list). @sarahmarshy feel free to submit this if you know the proper way of handling the exception!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is that correct behavior though? say src is C:\Project\mbed-os\src.cpp. Then relpath=mbed-os\src.cpp, then path_list = [mbed-os, src.cpp], which would be a list length >=1.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I created #3574 to fix this. This assert triggers in the case where the list is empty, as this is invalid and would cause an exception later anyway. This assert doesn't really matter though and I can remove it if you would like.

if len(path_list) == 1:
key = self.project_name
else:
key = path_list[0]
return key

def group_project_files(self, sources):
Expand Down