Tags
Date: Oct 27, 2023

pyM4B issue fixed

As some of you already know, during the past week we had an issue with pyM4B for which some panels were not displaying correctly.

I'm happy to announce that the problem is now fixed and here is how the most updated pyM4B looks like:

The root cause of the issue was something I didn't expect: the folder names on GitHub, at the moment of the commit, are not case-sensitive.

In practical terms, we changed the panel's name from "Coordination.panel" to "COORDINATION.panel" in both the folder name and in the boudle.yaml. On GitHub, an so your computers, only the boundle.yaml got changed, messing up the correct functioning of the extension.


In case you also publish regurarily on GitHub and are not aware of the issue, we'd like to spend a couple of lines more to show how we sorted this out.

How to rename folders on GitHub?

The solution to commit a folder with a different case is to pass through an intermediate commit where the folder name is different not only case-wise.

For instance, if you want to change a folder named "about.panel" into "About.panel", you should first commit something like "About.panel-----", and then you'll be able to commit back with the desired name "About.panel".

Considering the amount of folders in a pyRevit extension, I wrote a quick Python script that renames all the folders. It may not be the most elegant solution, but it worked like a charm and it was pretty fast. I'm sharing down here the script:

1import os
2
3def rename_nested(folder, suffix, add=True):
4    """
5    Order to follow to solve the case-sensitive issue:
6        1. run the function with add=True
7        2. commit the changes
8        3. run the function with add=False
9        4. commit for the last time
10    Args:
11        folder (str): the main folder to rename, with the nested as well
12        suffix (str): the unique string to add/remove from the path
13    """
14    amount = 0
15    for dirpath, dirnames, filenames in os.walk(folder):
16        for d in dirnames:
17            complete_dir = os.path.join(dirpath, d)
18            if add:
19                new_path = complete_dir+suffix
20            else:
21                new_path = complete_dir.replace(suffix,'')
22            os.rename(complete_dir, new_path)
23            amount += 1
24            amount += rename_nested(new_path, suffix, add)
25        break
26    return  amount
27
28folder = os.path.dirname(__file__)
29suffix = '-----'
30
31# rename_nested(folder, suffix, enum)
32amount = rename_nested(folder, suffix, add=False)
33print(f'{amount} folders renamed successfully.')

copied!

I hope this helps anyone who is facing the same issue.

Cheers!

Comments

New Comment

The e-mail is used to notify you any interaction with your comment
wip

We are working on it...