byteface / sharpshooter

A shorthand for creating files and folders. (A parser could be written in any language)
MIT License
11 stars 1 forks source link

- doesn't windows have backslash? #5

Closed github-actions[bot] closed 3 years ago

github-actions[bot] commented 3 years ago

This issue was automatically created by a github action that converts project Todos to issues.

https://github.com/byteface/sharpshooter/blob/0f6c3e759e2612b51b0fdba8655f58894cd425ee/sharpshooter/__init__.py#L468

                # with open(fileinfo['path'], 'r') as f:
                # fileinfo['data'] = f.read()

                try:
                    # if not the last line still need to navigate into it if it exists.
                    # also if not then stop nest ones being created also
                    os.chdir(os.path.join(self.cwd, folder_name))  # this should now error if it doesn't exist
                    self.depth += 1
                    self.cwd = os.getcwd()
                except FileNotFoundError as e:
                    sslog(f"""Folder '{folder_name}' not created. read_only. 

                    remove the colon from the line if you want to create the folder

                    """)
                    # raise e
                    self.is_dead = True
                    self.dead_depth = self.depth
                    # if self.depth == 0:
                        # self.is_dead = False
                        # self.dead_depth = 0 # hacky
                    self.depth += 1
                    # self.cwd = os.getcwd()

                    return

            else:
                if not self.delete:
                    if not os.path.exists(os.path.join(self.cwd, folder_name)):

                        if tree.TEST_MODE:
                            # TODO - doesn't windows have backslash?
                            sslog(f"TEST_MODE: create folder: {self.cwd}/{folder_name}")
                            self.depth += 1
                            self.cwd += f"/{folder_name}"
                            return
                        else:
                            os.mkdir(os.path.join(self.cwd, folder_name))
                            sslog("created folder", folder_name)
                        # os.mkdir(os.path.join(self.cwd, folder_name))
                    else:
                        sslog("folder already exists")