Jump to content
Korean Random
MarsOne

[improvement proposal] JSONxLoader loader.pyc Exception: File not found

Recommended Posts

Hi XVM-Developer,

 

i have a simple but good improvement proposal for the JSONxLoader.

 

Let's say, you make a mistake with a reference entry like this for example

...
${ "battleLabelTemplates.xc":"def.totalHP" }
//      ${ "battleLabelsTemplates.xc":"def.totalHP" }
...

Just a forgotten 's' in battleLabelsTemplates.xc...

 

Now you get as error notification just this:

JSONxLoaderException: File not found

But you have no idea, which filename you make this mistake with.

 

Now, lets change the WorldofTanks\res_mods\mods\xfw\python\lib\JSONxLoader\loader.pyc in line 85ff (95)

def load_file(self, path, encoding = 'utf-8-sig'):
        import codecs
        if path in self.file_cache:
            return self.file_cache[path]
        else:
            try:
                stream = codecs.open(path, 'r', encoding)
                self.file_cache[path] = stream.read()
                if self.log_func is not None:
                    self.log_func('[JSONxLoader] load: {}'.format(path))
                stream.close()
                return self.file_cache[path]
            except IOError as e:
                raise JSONxLoaderException('File not found', e.filename)
            return

to this

def load_file(self, path, encoding = 'utf-8-sig'):
        import codecs
        if path in self.file_cache:
            return self.file_cache[path]
        else:
            try:
                stream = codecs.open(path, 'r', encoding)
                self.file_cache[path] = stream.read()
                if self.log_func is not None:
                    self.log_func('[JSONxLoader] load: {}'.format(path))
                stream.close()
                return self.file_cache[path]
            except IOError as e:
                raise JSONxLoaderException('File not found: {}'.format(e.filename), e.filename)
            return

Then you get in case of Exeption also the filename which could not found!

JSONxLoaderException: File not found: res_mods\configs\xvm\default\battleLabelTemplates.xc

Great, or not?

What do you think. I guess it will be very helpful.

 

Edit: As an additional enhancement, maybe you could add the row and line position of the wrong reference at to message like we know it from your XVM :)

 

 

Friendly regards

MarsOne

Edited by MarsOne
  • Upvote 2

Share this post


Link to post

Short link
Share on other sites

Thanks very much.

 

Maybe you can help me now.

 

I don't use any specific vehicle names. Thats why i use in my config this:

{
  "vehicleNames": {
    "$ref": { "file":"../../default/vehicleNames.xc", "path":"vehicleNames" }
  }
}

My config is subfolder /user.. So i go two folders up and then to the default folder.

What's the correct entry for 'hardcoded' (sry for my poor english) config-folder?

 

This is not correct:

{
  "vehicleNames": {
    "$ref": { "file":"cfg://default/vehicleNames.xc", "path":"vehicleNames" }
  }
}

Do you understand and can help me?

"src" & "cfg"?

 

 

MarsOne

Edited by MarsOne

Share this post


Link to post

Short link
Share on other sites

 

 

I don't use any specific vehicle names.
You can delete "vehicleNames" section at all. Then XVM will use default values.

Share this post


Link to post

Short link
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...