I use PyCharm as my IDE for working with Django. So far, it's navigation shortcuts have proven very useful. I can go to a specific (project) file with Ctrl+Shift+N, I can go to any class definition with Ctrl+N and can go to any symbol with Ctrl+Shift+Alt+N.
This is great, but lately I've seen that it would be very useful too to have a shortcut to move to a specific external (or project) module.
Is there any shortcut where I can pass for example: django.contrib and show the modules for inside django.contrib package or base64 and show me the modules match for base64, just as easy as I can go to a specific, symbol, class, file?
I feel your problem. All you have to do is Ctrl + CLICK on the definition. Please note, however that this does not provide the actual files. What I mean by this is that it does not re-direct you to the actual function, but rather a skeleton of the function.
If you want to go to the actual function, you will need to go it it my clicking on external libraries on your sidebar and do a search.
Related
In my settings, I have the TODO bound to highlight in yellow, yet in the actual code it does not highlight. Here is a screenshot of my settings: Editor -> TODO
Does anyone know how to fix this?
EDIT: I even tried re-installing Pycharm and I still have the issue.
EDIT 2: In the TODO Window, it is saying "0 TODO items found in 0 files". I believe this means it is looking in the wrong files to check for TODO items. However, when I try to find TODO items in "this file" it still doesn't work. Does anyone know why this is?
Go to Preferences (or Settings), Project Structure, and make sure the folder with your files is not in the "Excluded" tab's list.
Click the folder you want to include and click on the "Sources" tab. Click Apply, then OK!
It should work.
I recently updated PyCharm Professional and my TODOs no longer worked. I went into settings and changed the alert icon, then saved, and retyped them and they worked. I imagine for my case, there was a delay in the new version picking them up. Might just need to retype them to get them working again, though the reboot should have addressed this.
Not sure if your pattern is causing this, but mine is set up like so, with two separate patterns:
\btodo\b.*
\bfixme\b.*
Neither is case sensitive, BTW...
Perhaps try some other patterns to see if you can get those to work.
I think the problem for me was the same as explained by #theBrownCoder but I couldn't find the project structure settings.
Apart from not showing TODO's another symptom was impossibility to go to function definitions defined in other files and inability to rename python files with the error: "Selected element is used from non-project files. These usages won't be renamed."
Googling for this the solution that worked for me was to delete the .idea folder (make sure to back it up just in case, you will lose the configurations).
I had the exact same problem, and the solution suggested by theBrownCoder worked perfectly.
For those who cannot find which menu theBrownCoder is referring to, go to File > Settings > Project: "Title of Project" > Project Structure.
It is in the dropdown of Project in Settings where you can also select your Python interpreter.
It might be the file type.
Right click, Override File Type.
I had this issue with a text file and it's copy, only the first one would use #TODO
I just switched from Eclipse/PyDev to PyCharm 3 CE. I can't get the live templates working any ways. Followed every documentation I can find online like this:
http://www.jetbrains.com/pycharm/webhelp/live-templates.html
And the builtin python template super(Generates a 'super' call) does not work either.
By "not working", I meant that when editing a python file in PyCharm and typing the abbreviation, the popup snippets list does not include the live templates, even though they are under the Python template group.
Am I missing something?
I am using PyCharm 3.1 Professional (evaluation version) and am having the same issue.
However, using Ctrl+J will bring up templates as will Code -> Insert Live Template. It is also possible to start typing a code snippet and then press Ctrl+J to see a filtered list of templates.
Don't forget to also select the "context"...
As an exercise for learning, I am trying to write a plugin for MusicBrainz that matches the albumartistsort to albumartist and artistsort to artist, as opposed to the (apparently) default of Last Name, First Name format it is currently using.
I am just learning about Python and therefore I am trying to use another plugin as a guide, but some important changes need to be done and that's where I probably screwed up.
When I try installing the plug in, it doesn't appear in the plugin list although it is copied to the plugin folder; and the .pyo file is not generated. I am guessing this is due to a compilation error, but I haven't been able to include whatever I need so I can use the picard module (don't know where to find it nor import it) so I can test in my python interpreter.
This is the code I have:
PLUGIN_NAME = "Sort Artist and Album Artist"
PLUGIN_AUTHOR = "Kevin Hernandez"
PLUGIN_DESCRIPTION = "Sorts artist/album artist by name as in Artist/Album Artist field instead of Last, First"
PLUGIN_VERSION = "0.1"
PLUGIN_API_VERSIONS = ["0.9.0", "0.10", "0.15", "0.16"]
from picard.metadata import register_album_metadata_processor
import re
def copy_albumartist_to_albumartistsort(tagger, metadata, release):
match = re.search($not($eq(metadata["albumartistsort"],metadata["albumartist"])))
if match:
metadata["albumartistsort"] = metadata["albumartist"]
def copy_artist_to_artistsort(tagger, metadata, release):
match = re.search($not($eq(metadata["artistsort"],metadata["artist"])))
if match:
metadata["artistsort"] = metadata["artist"]
register_album_metadata_processor(copy_albumartist_to_albumartistsort)
register_album_metadata_processor(copy_artist_to_artistsort)
and I also tried defining the functions as:
def copy_albumartist_to_albumartistsort(tagger, metadata, release):
metadata["albumartistsort"] = metadata["albumartist"]
def copy_artist_to_artistsort(tagger, metadata, release):
metadata["artistsort"] = metadata["artist"]
I must point out that I don't fully understand when these are called. I believe the plugin documentation here, here and here is not enough to follow the plugins they have there (e.g. the search and match methods they use in different plugins with re are not explained in the documentation links I am referring to.
If there's a more thorough documentation for it, you can pinpoint what I am doing wrong in my code, or know how to include the picard module in an interpreter (where to find it AND how to include it), then your comments are very much appreciated and valid answers to this question.
I think your biggest problem is that you're mixing up the plugin API with the tagger scripting language.
Tagger scripts are written in a simple custom language; plugins are written in Python. You can't mix and match syntax between the two languages. In particular:
match = re.search($not($eq(metadata["albumartistsort"],metadata["albumartist"])))
That $not, $eq, etc. doesn't mean anything in Python. If you want to check whether things are equal, you use the == operator. If you want to use re.search, you use regular expression syntax. And so on.
Also, your code has to be valid Python, with valid indentation. Your code, at least as posted here.
But let's go through your questions one by one:
I am trying to write a plugin for MusicBrainz that matches the albumartistsort to albumartist and artistsort to artist, as opposed to the (apparently) default of Last Name, First Name format it is currently using.
There are very few automatic defaults in MusicBrainz. Each artist has a name and a sort name, in the database, entered by a human user and verified by other users. You can see this from the web interface. For example, go to David Bowie, and in the "Artist Information" panel on the right side, you'll see "Sort name: Bowie, David". If you're not used to using MusicBrainz's web interface, you should explore it before trying to expand Picard.
When I try installing the plug in, it doesn't appear in the plugin list although it is copied to the plugin folder; and the .pyo file is not generated. I am guessing this is due to a compilation error
Yep. If you run Picard from the command-line with the -d flag, it will show you the errors instead of just silently disabling your plugin, so you don't have to guess. This is documented under Troubleshooting. (If you're on a Mac, the path will be something like /Applications/MusicBrainz Picard.app/Contents/MacOS/MusicBrainz Picard; I think the docs don't explain that because it's standard OS X app bundle stuff.)
but I haven't been able to include whatever I need so I can use the picard module (don't know where to find it nor import it) so I can test in my python interpreter.
You really can't test it in your interpreter. Picard bundles its own custom-built Python interpreter, rather than using your system Python. In that custom interpreter, the picard package is on the sys.path, but in your system Python interpreter, it's not. And trying to import that package and use things out of it while not actually running the Picard GUI wouldn't be a good idea anyway.
If you really want to explore what's in the picard package, download the source and run a local build of the code. But you really shouldn't need to do that. You shouldn't need any functions beyond those documented in the API, and if you want to debug things, you want to debug them in the right context, which generally means adding print functions and/or using the logging module in your code.
I must point out that I don't fully understand when these are called.
At some point after each album is downloaded from the MusicBrainz server, all registered album processor functions get called with the album, and all registered track processor function get called with each track on the album.
Notice that an album processor isn't going to be able to change track-level fields like the track artist sort; you will need a track processor for that.
e.g. the search and match methods they use in different plugins with re are not explained in the documentation links I am referring to.
That's because they're part of the Python standard library, which is documented as part of the standard Python docs—in this case, see re.
You're expected to know the basics of Python before being able to write a Picard plugin.
Meanwhile, I'm not sure what you were trying to write here, but it looks like a really convoluted attempt to say "if these two fields aren't equal, make them equal". Which does the same thing as "unconditionally make them equal". So, why even bother with the regexp and the if condition?
So, your functions could be simplified to:
def copy_albumartist_to_albumartistsort(tagger, metadata, release):
metadata["albumartistsort"] = metadata["albumartist"]
def copy_artist_to_artistsort(tagger, metadata, release, track):
metadata["artistsort"] = metadata["artist"]
register_album_metadata_processor(copy_albumartist_to_albumartistsort)
register_track_metadata_processor(copy_artist_to_artistsort)
However, you really don't need a plugin here at all. You should be able to write this whole thing as a trivial tagger script:
$set(artistsort,%artist%)
$set(albumartistsort,%albumartist%)
http://sublimerope.readthedocs.org/en/latest/cache_mechanisms.html
I want to add a custom directory from where I want auto completion. The Old Way mentioned on the above page does that job with prefs.add('python_path', '/home/abc/custom/')
, but the page says it's not recommended.
How can I do add a custom directory (say /home/abc/custom/) with the newer way mentioned on the page? It only explains how to add modules not directories.
If you haven't already, you should already have defined folders in your project settings. It looks like SublimeRope looks in those folders automatically, and you just define the modules you want to be included.
If you haven't already, I recommend taking a look at SublimeCodeIntel as well. I'm not terribly familiar with SublimeRope, but SCI is quite useful for my Python coding needs.
I'm working on an App Engine project that will have customizable themes. I'd like to be able to use jQuery UI themes. The problem is figuring out what the CSS file is going to be named. (Typically, "jquery-ui-1.7.2.custom.css". Version numbers will change, and people tend to rename things, but there should only be one CSS file, and I'm OK with it being an error condition if there's two or more for some reason.) Because it's a static file (static files are uploaded to App Engine separately from the rest of the application's resources), I can't just glob the directory for a CSS file. I can't just assume that it's hard-coded, and I really don't want to make it a configuration setting, because that's a bad user experience.
Guido told me to symlink it so that App Engine sees two copies and can treat one as static and the other as an application resource, but symlinks don't work on Windows, and since this will ultimately be open source, I can't control which SDK the user uses. Another suggestion was to use a deploy-time script, but Mac users have this nice "Deploy" button in their version of the SDK and I'd rather not have to tell them, "Oh hey, sorry for the inconvenience, but you can't use that for this project."
I clearly need an out-of-the-box solution to this one, but I'm at a loss. Anyone have any good suggestions for how to get a custom jQuery UI theme out of the ThemeRoller and into an App Engine app? Some post-processing is already needed, because the only files in the zip file that ThemeRoller gives you are in the "css" directory. Maybe I can write something that takes a raw theme as input and spits out something useful on the other side (the deploy-time script trick, but somehow less user-unfriendly). The trick here is presentation — I want the user to spend as little time on the command line as possible. An ideal solution assumes the person performing this task is non-technical for the most part. No part of the solution can be much harder than installing something like WordPress or Drupal, and in a perfect world, it should be way, way easier.
To accomplish what you are asking, I would use the datastore for serving the CSS files. Since this would allow easy listing, sorting and even modification and uploading.
Other than that, your next best options would be to store the CSS data inside a script (a dictionary where the filename is the key name, and the CSS code is the value). Or, as you suggested, to run a script before deploying to AppEngine.
Personally, I would go for the storing in the datastore option, since it will allow for a great deal more user customization (such as each user being able to provide their own CSS file), just be sure to use memcache to avoid needing to access the datastore when possible (which should be a very common occurrence), as well as using HTTP headers to tell the browser to cache the CSS file locally.