What are source and resource root in pycharm? - python-3.x

I'm developing a project about NLP. I have a large corpus and some code. I want to separate them in my project but I'm wondering what is the correct names to choose,
data vs code like in data segment and code segment in assembly, or
source and resource as one of my friends insists is the correct term.
I also saw something in pycharm menus as mark as source, mark as resource which I supposed is explained in here but I still can't understand what are these source and resource root things and when should I use them. I used to think of resource as time, energy, computational power etc.

answers from JetBrains Content root types
Content root types
By default, all the files in a content root folder are involved in indexing, searching, parsing, code completion, and so on. To change this status, folders within a content root can be assigned to the following categories:
Regular content roots, created as described in Configuring Project Structure. These roots are marked the Content root icon.
A content root is a folder that contains the files that make up your project.
Source roots (or source folders; shown as the Source root icon ).
These roots contain the actual source files and resources. PyCharm uses the source roots as the starting point for resolving imports.
The files under the source roots are interpreted according to their type. PyCharm can parse, inspect, index, and compile the contents of these roots.
Resource roots (PyCharm Professional only) or resource folders; shown as the Resources root icon the Resources root icon.
These roots are intended for resource files in your application (images, style sheets, and so on). By assigning a folder to this category, you tell PyCharm that files in it and in its subfolders can be referenced relative to this folder instead of specifying full paths to them.
Excluded roots (shown as the Excluded root icon) are ones that PyCharm "almost ignores".
These roots contain files and folders ignored by PyCharm when indexing, searching, parsing, watching and so on.
Excluded roots are not visible to PyCharm. Usually, one would like to exclude temporary build folders, generated output, logs, and other project output. Excluding the unnecessary paths is a good way to significantly improve performance.
Template roots (PyCharm Professional only) marked as the Template Folder icon contain templates for the various web projects.

"Resource" is a more general term than "data". By "data" one usually means the input to a program, something that will influence its output and which can be different in each execution.
But there are other types of files that have a more permanent function, for example the icon images used by a program's graphical interface. This type of file would also be placed in a resource directory because it needs to be accessed during execution to assemble the interface. Another example of resources could be translation files (each translation file containing the translated messages used by the program in a specific language).
By those definitions, your text corpuses can be seen as "data" since you might want to apply your program to different corpuses in the future, or as a "resource" if they are more fixed and used as a sort of reference for the program to solve queries based on other user input.
Naturally we can also see things like icon image files as "data" if we plan to change them often and regard them as the input to our program, but that would be atypical.
Overall the boundary between "data" and "resources" are kind of blurry but that would be the overall idea.

Related

Organizing common files in a separate area in depot

Typically, we have a depot root for every different product that we work on. For e.g.:
//products/productX
/productY
As the common files in the 2 products increase, I would like to put them into a top level folder of it's own
//products/productX
/productY
/common
Now to ensure that this works for all the users who have existing workspace, we would need to update all their workspaces. Is there an alternative? Can we put some markers in the depot to create a link it to a different folder? Any other option?
What you're describing is essentially the reason that streams were created -- the idea of a stream is that you definition the structure of a codeline in one place (e.g. "product X lives in //products/productX"), multiple people base their workspaces on that, and when you change it (e.g. "product X lives in //products/productX + //products/common), every workspace based on that definition updates automatically.
So if you're using streams, all you need to do is update the stream definitions that need to include the new //products/common directory. Easy!
If you're using "classic" workspaces, users who are using the default //products/... mapping will get the common directory automatically regardless. For users with custom views, my suggestion would be to alert them of the refactor and then let them make their own adjustments as appropriate; if they're familiar enough with Perforce to have built a custom client view, they may not appreciate having it changed underneath them.

Installshield Basic MSI project : Display logo dynamically from a folder which is not part of the installation

I am new to Installshield and I want to display the banners displayed in the dialogs during installation to be fetched dynamically from an external folder which resides in the path of the setup.exe (not part of the installation) using Installshield Basic MSI project.
I tried specifying the “File Name” for the banner bitmaps in the dialog as <SETUPEXEDIR>\MyLogo\Test.bmp. But this gives an error as “File not found. Error streaming file to binary table.” when the project is built.
Is there a way possible to achieve this?
Windows Installer requires that the images are baked into the .msi file in order to display them (it saves the bits, not the name, in the Binary table), so it's very reasonable to summarize this as not supported.
As a possible workaround (one I'm uncertain whether it can work), it's feasible that a custom action could write temporary records to the Binary table or Control table that containing the image found at run time. Note that this sort of custom action is somewhere between admitting failure and a semi-custom action. Furthermore finding the image, dealing with incorrect image sizes, determining which dialog boxes need the added image Binary or Control record, and possibly deleting an existing Binary or Control record, are left as exercises for an eager reader.

Installshield Installscript properties

We have Installshield 2009 for our product. I am trying to muddle my way through it to make some updates (obviously, I am not the original author).
Within, there is a fairly complex arrangement of components and files, plus, there is a script section for some custom work.
I need to accomplish the following, without creating a blank object in the repository.
One of the components needs to create a directory tree (two folders deep).
Within that tree (deepest folder), I need to create a blank file.
Questions:
Do I need to create two components, one for each directory level, or will the tree be created if I specify [INSTALLDIR]folder1\folder2?
I am thinking that the installscript would be the place to create the empty file, based on the CreateFile example in the help. I notice that, in the components page, that, once I typed the value for the Destination property, that a little "tag" of sorts appeared at the start {FOLDER2}. Can I used that tag as an argument to CreateFile and how would I reference it?
Regardless of the project type, I would probably suggest creating the folder structure in the Files and Folders view, and adding the empty file there. It's just simple and you'd be done with fewer chances of error.
As to the questions you asked, neither Basic MSI nor InstallScript projects require components for every folder level on the system. Note that if the folder isn't already there when it executes, the CreateFile approach is unlikely to create the folders for you.
In a Basic MSI project, {FOLDER2} indicates that FOLDER2 is the name of the directory entry, and after CostFinalize there will be a property of the same name that contains its run-time location. You can retrieve it in an InstallScript custom action with MsiGetProperty. In a pure InstallScript project the approach would be a little different, worst case it would be something like TARGETDIR ^ "folder1" ^ "folder2" (my InstallScript is rusty).

How to load files in a specific order

I would like to know how I can load some files in a specific order. For instance, I would like to load my files according to their timestamp, in order to make sure that subsequent data updates are replayed in the proper order.
Lets say I have 2 types of files : deal info files and risk files.
I would like to load T1_Info.csv, then T1_Risk.csv, T2_Info.csv, T2_Risk.csv...
I have tried to implement a comparator, as it is said on Confluence, but it seems that the loadInstructions file has the priority. It will order the Info files and the risk files independently. (loading T1_Info.csv, T2_Info.csv and then T1_Risk.csv, T2_Risk.csv..)
Do I have to implement a custom file loader, or is it possible using an AP configuration ?
The loading of the files based on load instructions is done in
com.quartetfs.tech.store.csv.impl.CSVDataModelFactory.load(List<FileLoadDescriptor>). The FileLoadDescriptor list you receive is created directly from the load instructions files.
What you can do is create a simple instructions files with 2 entries, one for deal info and one for risk. So your custom implementation of CSVDataModelFactory will be called with a list of two items. In your custom implementation you scan the directory where the files are, sort them in the order you want them to be parsed and call the super.load() with the list of FileLoadDescriptor you created from the directory scanning.
If you want to also load files that are place in the future in this folder you have to add to your load instructions a line that will match all files and that will make the super.load() implementation to create a directory watcher for that (you should then maybe override createDirectoryWatcher() to not watch the files already present in the folder when load is called).

XUL accessing resources and application structure

So I'm new to XUL.
As a language it seems easy enough and I'm already pretty handy at javascript, but the thing I can't wrap my mind around is the way you access resources from manifest files or from xul files. So I did the 'Getting started with XULRunner' tutorial... https://developer.mozilla.org/en/getting_started_with_xulrunner
and I'm more confused than ever... so I'm hoping someone can set me straight.
Here is why... (you may want to open the tutorial for this).
The manifest file, the prefs.js and the xul file all refer to a package called 'myapp', that if everything I've read thus far on MDN can be trusted means that inside the chrome directory there must be either a jar file or directory called myapp, but there is neither. The root directory of the whole app is called myapp, but I called mine something completely different and it still worked.
When I placed the content folder, inside another folder called 'foo', and changed all references to 'myapp' to 'foo', thus I thought creating a 'foo' package, a popup informed me that it couldn't find 'chrome://foo/content/main.xul', though that's exactly where it was.
Also in the xul file it links to a stylesheet inside 'chrome://global/skin/' which doesn't exist. Yet something is overriding any inline styling I try to do to the button. And when I create a css file and point the url to it, the program doesn't even run.
Can someone please explain what strange magic is going on here... I'm very confused.
When you register a content folder in a chrome.manifest you must use the following format:
content packagename uri/to/files/ [flags]
The uri/to/files/ may be absolute or relative to the location of the manifest. That is, it doesn't matter what the name of the containing folder is relative to your package name; the point is to tell chrome how to resolve URIs of the following form:
chrome://packagename/content/...
The packagename simply creates a mapping to the location of the files on disk (wherever that may be).
The chrome protocol defines a logical package structure, it simply maps one URL to another. The structure on disk might be entirely different and the files might not even be located on disk. When the protocol handler encounters an address like chrome://foo/content/main.xul it checks: "Do we have a manifest entry somewhere that defines the content mapping for package foo?" And if it then finds content foobar file:///something/ - it doesn't care whether that URL refers to a file, it simply resolves main.xul relatively to file:///something/ which results in file:///something/main.xul. So file:///something/browser.xul will be the URL from which the data will be read in the end - but you could also map a chrome package to another chrome URL, a jar URL or something else (theoretically you could even use http but that is forbidden for security reasons).
If you look into the Firefox/XULRunner directory you will see another chrome.manifest there (in Firefox 4/5 it is located inside omni.jar file). That's where the mappings for global package are defined for example.

Resources