Permalink
Browse files

lint police

  • Loading branch information...
1 parent 7e192f1 commit a789bf9d284908411f598944bfe80fe8b79d79a6 @trey0 trey0 committed Nov 1, 2012
@@ -4,7 +4,7 @@
# All Rights Reserved.
# __END_LICENSE__
-MAX_IMPORT_FILE_SIZE = 2097152 # bytes
+MAX_IMPORT_FILE_SIZE = 2097152 # bytes
# This feature is rigged to be disabled due to the planned removal of the Appengine PDF service
PDF_IMPORT_ENABLED = True
@@ -62,4 +62,3 @@
# aligned tiles from public overlays can be viewed by any non-logged-in
# user, even though the app is in private beta.
GEOCAM_TIE_POINT_PUBLIC_BY_DEFAULT = True
-
View
@@ -18,7 +18,7 @@ def clean(self):
image_file = cleaned_data.get("image")
image_url = cleaned_data.get("imageUrl")
- if not bool(image_file) ^ bool(image_url): # logical xor
+ if not bool(image_file) ^ bool(image_url): # logical xor
raise ValidationError("Requires a URL or uploaded image, but not both.")
return cleaned_data
View
@@ -151,7 +151,6 @@ def getGeneratorCacheKey(cls, quadTreeId):
@classmethod
def getGeneratorWithCache(cls, quadTreeId):
- global cachedGeneratorG
cachedGeneratorCopy = getattr(cachedGeneratorG, 'gen',
{'key': None, 'value': None})
key = cls.getGeneratorCacheKey(quadTreeId)
@@ -25,7 +25,7 @@
from django.core.cache import cache
-from geocamTiePoint import transform, settings
+from geocamTiePoint import transform
TILE_SIZE = 256.
PATCH_SIZE = 32
@@ -15,25 +15,32 @@ $(function($) {
app.models.Overlay = Backbone.Model.extend({
idAttribute: 'key', // Backend uses "key" as the primary key
- initialize: function(){
- // Bind all the model's function properties to the instance, so they can be passed around as event handlers and such.
+ initialize: function() {
+ // Bind all the model's function properties to the instance,
+ // so they can be passed around as event handlers and such.
_.bindAll(this);
this.on('before_warp', this.beforeWarp);
- this.on('change:exportUrl', function(){
- if ( this.exportPending && this.get('exportUrl') ) {
+ this.on('change:exportUrl', function() {
+ if (this.exportPending && this.get('exportUrl')) {
console.log('Export trigger.');
}
}, this);
- this.on('export_ready', function(){ console.log('Export Ready!'); } );
+ this.on('export_ready', function() {
+ console.log('Export Ready!');
+ });
},
url: function() {
- var pk = _.isUndefined(this.get('id')) ? this.get('key') : this.get('id');
+ var pk = (_.isUndefined(this.get('id')) ?
+ this.get('key') : this.get('id'));
return this.get('url') || '/overlay/' + pk + '.json';
},
getImageTileUrl: function(coord, zoom) {
- assert( this.get('unalignedTilesUrl'), "Overlay is missing an unalignedTilesUrl property. Likely it does not have an unalignedQuadTree set on the backend.");
+ assert(this.get('unalignedTilesUrl'),
+ 'Overlay is missing an unalignedTilesUrl property.' +
+ ' Likely it does not have an unalignedQuadTree set' +
+ ' on the backend.');
var normalizedCoord = getNormalizedCoord(coord, zoom);
if (!normalizedCoord) { return null; }
var url = fillTemplate(this.get('unalignedTilesUrl'), {
@@ -46,7 +53,7 @@ $(function($) {
parse: function(resp, xhr) {
// Ensure server-side state never overwrites local points value
- if ( this.has('points') && 'points' in resp ) {
+ if (this.has('points') && 'points' in resp) {
delete resp.points;
}
return resp;
@@ -93,24 +100,27 @@ $(function($) {
},
/**
- * Update one "side" (map or image) of an entry in the model's tipeoing array.
- * Will add a new tiepoint if one doesn't already exist at that index.
+ * Update one "side" (map or image) of an entry in the model's
+ * tiepoint array. Will add a new tiepoint if one doesn't
+ * already exist at that index.
*/
- updateTiepoint: function( whichSide, pointIndex, coords ) {
+ updateTiepoint: function(whichSide, pointIndex, coords) {
var points = this.get('points');
var initial_length = points.length;
- var tiepoint = points[pointIndex] || [null,null,null,null];
- var coordIdx= {
- 'map': [0,1],
- 'image': [2,3],
+ var tiepoint = points[pointIndex] || [null, null, null, null];
+ var coordIdx = {
+ 'map': [0, 1],
+ 'image': [2, 3]
}[whichSide];
- assert(coordIdx, "Unexpected whichSide argument: "+whichSide);
+ assert(coordIdx, 'Unexpected whichSide argument: ' + whichSide);
tiepoint[coordIdx[0]] = coords.x;
tiepoint[coordIdx[1]] = coords.y;
points[pointIndex] = tiepoint;
this.set('points', points);
- if (points.length > initial_length) this.trigger( 'add_point' );
- this.trigger('change:points'); // Manually trigger this, because the value of model.points (an array reference) hasn't actually changed.
+ if (points.length > initial_length) this.trigger('add_point');
+ // Manually trigger this, because the value of model.points
+ // (an array reference) hasn't actually changed.
+ this.trigger('change:points');
},
deleteTiepoint: function(index) {
@@ -124,21 +134,28 @@ $(function($) {
computeTransform: function() {
// only operate on points that have all four values.
- var points = _.filter(this.get('points'), function(coords){return _.all(coords, _.identity);});
- if ( points.length <2 ) return false; // a minimum of two tiepoints are required to compute the transform
+ var points = _.filter(this.get('points'), function(coords) {
+ return _.all(coords, _.identity);
+ });
+ // a minimum of two tiepoints are required to compute the transform
+ if (points.length < 2) return false;
this.set('transform',
- points ? geocamTiePoint.transform.getTransform(points).toDict() : {type: '', matrix: []}
+ (points ?
+ geocamTiePoint.transform.getTransform(points).toDict() :
+ {type: '', matrix: []})
);
},
save: function(attributes, options) {
// Always compute transform on before save.
this.computeTransform();
- return Backbone.Model.prototype.save.call(this, attributes, options);
+ return Backbone.Model.prototype.save.call(this, attributes,
+ options);
},
beforeWarp: function() {
- this.unset('exportUrl'); // We have to clear this because this.fetch() won't.
+ // We have to clear this because this.fetch() won't.
+ this.unset('exportUrl');
},
warp: function(options) {
@@ -147,8 +164,8 @@ $(function($) {
var model = this;
model.trigger('before_warp');
saveOptions = {
- error: function(model, response){
- if ( response.readyState < 4 ) {
+ error: function(model, response) {
+ if (response.readyState < 4) {
model.trigger('warp_server_unreachable');
} else {
model.trigger('warp_server_error');
@@ -158,20 +175,22 @@ $(function($) {
success: function(model, response) {
if (options.success) options.success();
model.trigger('warp_success');
- },
- }
+ }
+ };
this.save({}, saveOptions);
},
startExport: function(options) {
//this.unset('exportUrl');
- assert(! this.get('exportUrl'), "Model has an exportUrl already.");
- var request_url = this.get('url').replace('.json', '/generateExport/');
+ assert(! this.get('exportUrl'), 'Model has an exportUrl already.');
+ var request_url = this.get('url').replace('.json',
+ '/generateExport/');
this.exportPending = true;
var model = this;
- model.on('export_ready', function(){this.exportPending = false;}, this);
- $.post(request_url, '', function(){
- model.fetch({ success: function(){
+ model.on('export_ready', function() {this.exportPending = false;},
+ this);
+ $.post(request_url, '', function() {
+ model.fetch({ success: function() {
/* on app engine our request to generate an export
gets an immediate response from the server
because the actual work is done in the background
@@ -182,14 +201,15 @@ $(function($) {
*/
} });
}, 'json')
- .error(function(xhr, status, error){
+ .error(function(xhr, status, error) {
this.exportPending = false;
if (options.error) options.error();
});
this.pollUntilExportComplete(model);
},
- pollUntilExportComplete: function pollForExportComplete(model, timeout){
+ pollUntilExportComplete: function pollForExportComplete(model,
+ timeout) {
if (!model.exportPending) return false;
this.fetch();
if (this.get('exportUrl')) {
@@ -198,11 +218,10 @@ $(function($) {
}
// exponential backoff on polling
var timeout = timeout ? 1.5 * timeout : 1000;
- console.log("polling overlay: " + timeout);
- this.pollTimer = setTimeout(_.bind(pollForExportComplete, this), timeout, model, timeout);
- },
-
-
+ console.log('polling overlay: ' + timeout);
+ this.pollTimer = setTimeout(_.bind(pollForExportComplete, this),
+ timeout, model, timeout);
+ }
});
@@ -211,8 +230,8 @@ $(function($) {
url: '/overlays.json',
comparator: function(overlay) {
// Sort by modified time, descending
- return -1 * Date.parse( overlay.get('lastModifiedTime') );
- },
+ return -1 * Date.parse(overlay.get('lastModifiedTime'));
+ }
});
app.overlays = new app.OverlayCollection();
@@ -28,7 +28,7 @@ $(function($) {
view.render();
},
- reloadToFixMapIfNeeded: function () {
+ reloadToFixMapIfNeeded: function() {
// HACK: force reload to avoid problems the second time we
// render a map in the same tab
this.numMapViews++;
@@ -82,15 +82,19 @@ $(function($) {
* Support for undo/redo global functions
*/
window.getState = function() {
- if (app.currentView && app.currentView.getState) return app.currentView.getState();
+ if (app.currentView && app.currentView.getState) {
+ return app.currentView.getState();
+ }
};
window.setState = function(state) {
- if (app.currentView && app.currentView.setState) return app.currentView.setState(state);
+ if (app.currentView && app.currentView.setState) {
+ return app.currentView.setState(state);
+ }
};
//Keep the content container height in sync with the window
- $(window).resize(function(e){
+ $(window).resize(function(e) {
var container = $('#contents');
- container.height( $(window).height() - container.offset().top );
+ container.height($(window).height() - container.offset().top);
}).resize();
});
Oops, something went wrong.

0 comments on commit a789bf9

Please sign in to comment.