GithubHelp home page GithubHelp logo

output is not reproducible about gpxpy HOT 3 CLOSED

tkrajina avatar tkrajina commented on May 23, 2024
output is not reproducible

from gpxpy.

Comments (3)

tkrajina avatar tkrajina commented on May 23, 2024

Yes, I'm aware of this problem.

I just pushed a quickfix for this here: 75381db

It will sort the attributes each time if there is more than one attribute.

Now, this has a small performance penalty and it works only with python2. I'll try to think for a better solution. Of course, ideas are welcome.

from gpxpy.

wrohdewald avatar wrohdewald commented on May 23, 2024

how about using OrderedDict? It exists since Python 2.7

--- a/gpxpy/gpx.py
+++ b/gpxpy/gpx.py
@@ -2582,11 +2582,11 @@ class GPX:
self.creator = 'gpx.py -- https://github.com/tkrajina/gpxpy'

     v = version.replace('.', '/')
  •    xml_attributes = {
    
  •            'xmlns:xsi': 'http://www.w3.org/2001/XMLSchema-instance',
    
  •            'xmlns': 'http://www.topografix.com/GPX/%s' % v,
    
  •            'xsi:schemaLocation': 'http://www.topografix.com/GPX/%s http://www.topografix.com/GPX/%s/gpx.xsd' % (v, v)
    
  •    }
    
  •    xml_attributes = mod_collections.OrderedDict([
    
  •            ('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance'),
    
  •            ('xmlns', 'http://www.topografix.com/GPX/%s' % v),
    
  •            ('xsi:schemaLocation', 'http://www.topografix.com/GPX/%s http://www.topografix.com/GPX/%s/gpx.xsd' % (v, v))
    
  •    ])
    
       content = mod_gpxfield.gpx_fields_to_xml(self, 'gpx', version, custom_attributes=xml_attributes)
    

from gpxpy.

tkrajina avatar tkrajina commented on May 23, 2024

Yes, it makes sense. Although, now that I look at it, the custom_attributes named parameter is used only once, so even the dict.sort() wouldn't be such a problem.  But, on the other side, there is no sort() for {}.items() in py3. And if OrderedDict is the only reason to break py2.6, I'll just not sort but expect the attrs to be a list:

8abebca

...and it will work everywhere.

Thanks for your help!

from gpxpy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.