Skip to content
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

Add support for relative path for nested include #28

Merged
merged 7 commits into from Aug 15, 2017

Conversation

loicgasser
Copy link
Contributor

@loicgasser loicgasser commented Aug 4, 2017

Not sure what you tried to accomplish with cwd, append absolute paths?

According to me in mapfile you have either

  • relative paths
  • absolute paths

It seems that it was overriden every time when calling parse_file, which is not something I'd expect and I couldn't find any test for cwd argument.

Hope that you are happy with these changes.

In the utils section I added all the options you can give the parser (namely add_linebreaks for loads and expand_includes + add_linebreaks for load)

DOC:
http://mapserver.org/mapfile/include.html

Supported in versions 4.10 and higher.

The name of the file to be included MUST be quoted (single or double quotes).

Includes may be nested, up to 5 deep.

File location can be given as a full path to the file, or (in MapServer >= 4.10.1) as a path relative to the mapfile.

@loicgasser loicgasser force-pushed the cwd_override branch 2 times, most recently from a175521 to 737afae Compare August 4, 2017 15:58
@loicgasser loicgasser changed the title Add support for relative path for include Add support for relative path for nested include Aug 4, 2017
@geographika
Copy link
Owner

@loicgasser - I'll need to get some time to review this in more detail. Thanks for the comments and pull request. From memory I was using the cwd parameter so that I could load a mapfile from a string with relative includes, and load these from disk.

@loicgasser
Copy link
Contributor Author

ok thanks, I can adapt/change it if you guide me.

@@ -66,11 +68,9 @@ def open_file(self, fn):
raise

def parse_file(self, fn):

self.cwd = os.path.dirname(fn)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

main issue was that. always the same cwd which was overriden here


assert (len(parts) == 2)
assert (parts[0].lower() == 'include')
fn = os.path.join(self.cwd, self.strip_quotes(parts[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.

and as a result this would not follow relative nested paths.

@geographika geographika merged commit e526cdd into geographika:master Aug 15, 2017
@geographika
Copy link
Owner

@loicgasser - thanks for this. Merged. I increased the line length for flake8 as the default of 80 is quite low.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants