mirror of
				https://github.com/f-droid/fdroidserver.git
				synced 2025-11-03 22:20:28 +03:00 
			
		
		
		
	use OrderedDict for localization data in index-v1
This commit is contained in:
		
							parent
							
								
									26192a00e2
								
							
						
					
					
						commit
						89d9d0c45b
					
				
					 2 changed files with 20 additions and 4 deletions
				
			
		| 
						 | 
				
			
			@ -169,6 +169,11 @@ def make_v1(apps, packages, repodir, repodict, requestsdict, fdroid_signing_key_
 | 
			
		|||
            # Java prefers milliseconds
 | 
			
		||||
            # we also need to accound for time zone/daylight saving time
 | 
			
		||||
            return int(calendar.timegm(obj.timetuple()) * 1000)
 | 
			
		||||
        if isinstance(obj, dict):
 | 
			
		||||
            d = collections.OrderedDict()
 | 
			
		||||
            for key in sorted(obj.keys()):
 | 
			
		||||
                d[key] = obj[key]
 | 
			
		||||
            return d
 | 
			
		||||
        raise TypeError(repr(obj) + " is not JSON serializable")
 | 
			
		||||
 | 
			
		||||
    output = collections.OrderedDict()
 | 
			
		||||
| 
						 | 
				
			
			@ -208,6 +213,17 @@ def make_v1(apps, packages, repodir, repodict, requestsdict, fdroid_signing_key_
 | 
			
		|||
                k = k[:1].lower() + k[1:]
 | 
			
		||||
            d[k] = v
 | 
			
		||||
 | 
			
		||||
    # establish sort order in localized dicts
 | 
			
		||||
    for app in output['apps']:
 | 
			
		||||
        localized = app.get('localized')
 | 
			
		||||
        if localized:
 | 
			
		||||
            lordered = collections.OrderedDict()
 | 
			
		||||
            for lkey, lvalue in sorted(localized.items()):
 | 
			
		||||
                lordered[lkey] = collections.OrderedDict()
 | 
			
		||||
                for ikey, iname in sorted(lvalue.items()):
 | 
			
		||||
                    lordered[lkey][ikey] = iname
 | 
			
		||||
            app['localized'] = lordered
 | 
			
		||||
 | 
			
		||||
    output_packages = collections.OrderedDict()
 | 
			
		||||
    output['packages'] = output_packages
 | 
			
		||||
    for package in packages:
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -133,12 +133,12 @@
 | 
			
		|||
      "lastUpdated": 1466640000000,
 | 
			
		||||
      "localized": {
 | 
			
		||||
        "en-US": {
 | 
			
		||||
          "name": "title\n",
 | 
			
		||||
          "summary": "short description\n",
 | 
			
		||||
          "video": "video\n",
 | 
			
		||||
          "description": "full description\n",
 | 
			
		||||
          "featureGraphic": "featureGraphic.png",
 | 
			
		||||
          "icon": "icon.png"
 | 
			
		||||
          "icon": "icon.png",
 | 
			
		||||
          "name": "title\n",
 | 
			
		||||
          "summary": "short description\n",
 | 
			
		||||
          "video": "video\n"
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue